IPMI sensors -- update June 21, 2009

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

IPMI sensors -- update June 21, 2009

Post by ehall »

I have been working to get different kinds of hardware monitoring working in a consistent manner. This is the package for using ipmitool to query a system over the IPMI management interface.

Here is what the final result looks like for one of my systems, and shows the fan speeds, thermal probe temperatures, and voltage levels for all of the available sensors on that server:

Image

This model uses ipmitool to ask the target for all known sensors of the requested type. Add the appropriate data query to a device that has an IPMI interface, and then create new graphs for each of the sensors that you want. Each selected sensor will be created as an individual data-source and graph, like with interfaces.

--> see this page for the tarball and instructions <--
Last edited by ehall on Tue Jun 23, 2009 11:26 am, edited 11 times in total.
bsod
Posts: 23
Joined: Thu Mar 11, 2004 11:49 am
Location: Paris, France

Post by bsod »

Thanks a lot for this ! I'll try it very soon ...
error27
Posts: 1
Joined: Thu Feb 16, 2006 8:37 pm

Post by error27 »

I'm trying to run the ipmi_sensors.php script manually like this:
php ipmi/ipmi_sensors.php VOLTAGE 192.168.98.131 "" "" query sensorreading

At first it was cutting off the last character of the hostname so it wasn't working so I had to patch it.

Code: Select all

--- ipmi/ipmi_sensors.php.orig  2006-02-16 17:39:18.000000000 -0800
+++ ipmi/ipmi_sensors.php       2006-02-16 17:39:26.000000000 -0800
@@ -62,7 +62,7 @@
 #
 # 2nd parameter is always $hostname
 #
-$hostname = substr($_SERVER['argv'][2],0,(strlen($_SERVER['argv'][2]) - 1));
+$hostname = substr($_SERVER['argv'][2],0,(strlen($_SERVER['argv'][2])));

 if ($hostname == (exec ('hostname -f 2>/dev/null'))) {

I'm a newbie at using cacti so I'm not able to make it work as a plugin. Someone said that you just put the .php scripts in /usr/share/cacti/scripts/ but that doesn't seem to work.

I imported the .xml files. Those seem to be looking for files like:
/usr/share/cacti/rra/<hostname>_sensorreading_11.rrd
But no sensorreading files have been created so it's not working. :/

What am I doing wrong?
dgrossato
Posts: 2
Joined: Wed Feb 22, 2006 11:56 am

I've tried in several manner but...

Post by dgrossato »

I've corrected the script as above shown,
The script runs from console,
I've imported for now only the single (not 8x ) template without modifing them,
I've tried setup input method in several way but...
I haven't obtained nothig... only an empty graph
I spent several full day on it, I read most docs in this site but nothing...
I think that a single post is necessary to show how to setup it...

TNX
DvD
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Post by ehall »

error27 wrote:I'm trying to run the ipmi_sensors.php script manually like this:
php ipmi/ipmi_sensors.php VOLTAGE 192.168.98.131 "" "" query sensorreading

At first it was cutting off the last character of the hostname so it wasn't working so I had to patch it.
Don't do that. The query definition XML uses comma-separated parameters, and the script chops the commas off. Since your patch is not doing that anymore, hostname lookups are now going to be for "hostname," (with the comma) and the subsequently fields will also be imbalanced.
I'm a newbie at using cacti so I'm not able to make it work as a plugin. Someone said that you just put the .php scripts in /usr/share/cacti/scripts/ but that doesn't seem to work.

I imported the .xml files. Those seem to be looking for files like:
/usr/share/cacti/rra/<hostname>_sensorreading_11.rrd
But no sensorreading files have been created so it's not working. :/

What am I doing wrong?
First make sure that the script works with the commas using something simple like "php ipmi_sensors.php VOLTAGE, 192.168.98.131, ," (the empty parameters will be filled in by the script).

Second make sure the files are in the right place. The PHP script file should be in your $cacti/scripts/ directory (you seem to have it in an ipmi subdirectory), and the XML files should be imported (using the "Import Templates" menu option on the left side of the console screen).

Third make sure the IPMI device has an IP address, and that it responds to SNMP or ICMP ping (set community string to blank to bypass SNMP lookups). Cacti will not execute any lookups for the device if it does not respond to basic probes.

Once that's all working, add the data query to the device in the console screen, and then use the verbose option to display the discovered sensors. If there aren't any sensors and the error isn't obvious, copy and paste the verbose output here and I'll see if I can spot the problem.
dgrossato
Posts: 2
Joined: Wed Feb 22, 2006 11:56 am

My setup

Post by dgrossato »

ehall wrote:
error27 wrote:I'm trying to run the ipmi_sensors.php script manually like this:
php ipmi/ipmi_sensors.php VOLTAGE 192.168.98.131 "" "" query sensorreading

At first it was cutting off the last character of the hostname so it wasn't working so I had to patch it.
Don't do that. The query definition XML uses comma-separated parameters, and the script chops the commas off. Since your patch is not doing that anymore, hostname lookups are now going to be for "hostname," (with the comma) and the subsequently fields will also be imbalanced.
OK, fixes now script goes like this:

Code: Select all

/usr/bin/php ./scripts/ipmi_sensors.php TEMPERATURE "", "", "", query sensorname
1:Temp
2:Temp
3:Ambient Temp
4:Planar Temp
5:Riser Temp
6:Temp
7:Temp
8:Temp
9:Temp
10:Ambient Temp
11:Planar Temp
12:Riser Temp
13:Temp
14:Temp
I'm a newbie at using cacti so I'm not able to make it work as a plugin. Someone said that you just put the .php scripts in /usr/share/cacti/scripts/ but that doesn't seem to work.

I imported the .xml files. Those seem to be looking for files like:
/usr/share/cacti/rra/<hostname>_sensorreading_11.rrd
But no sensorreading files have been created so it's not working. :/

What am I doing wrong?
Attention permission for /var/lib/cacti/ where scripts and rras are stored. In fedora FC4 with SELinux enable the are also the context permission -> try with

Code: Select all

chcon -R --reference=/var/www/html/ /var/lib/cacti/
Link
ehall wrote: First make sure that the script works with the commas using something simple like "php ipmi_sensors.php VOLTAGE, 192.168.98.131, ," (the empty parameters will be filled in by the script).
I setup the scritps to "" - (empty) -> localhost now in "Data Inputs Method" I have

- IPMI - Tools - Temperature

- Script query

- /usr/bin/php <path_cacti>/scripts/ipmi_sensors.php TEMPERATURE "", "", "",

- Input - nothing

- Output - nothing

ehall wrote: Second make sure the files are in the right place. The PHP script file should be in your $cacti/scripts/ directory (you seem to have it in an ipmi subdirectory), and the XML files should be imported (using the "Import Templates" menu option on the left side of the console screen).
OK Done.
ehall wrote: Third make sure the IPMI device has an IP address, and that it responds to SNMP or ICMP ping (set community string to blank to bypass SNMP lookups). Cacti will not execute any lookups for the device if it does not respond to basic probes.
I setup this to "" (empty) -> localhost (cacti is running on the same server to monitor)
ehall wrote: Once that's all working, add the data query to the device in the console screen, and then use the verbose option to display the discovered sensors. If there aren't any sensors and the error isn't obvious, copy and paste the verbose output here and I'll see if I can spot the problem.
Graph are empty

Code: Select all

RRDTool Command:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Localhost - Thermal Sensor - |query_sensorName|" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="Celsius" \
DEF:a="/usr/share/cacti/rra/localhost_sensorreading_14.rrd":sensorReading:AVERAGE \
LINE2:a#0000FF:"|query_sensorName|"  \
GPRINT:a:LAST:"Current\:%8.2lf %s"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s"  \
GPRINT:a:MIN:"Minimum\:%8.2lf %s"  \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" 

RRDTool Says:

OK
thats all folks!!!

Bye Bye
DvD
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Re: My setup

Post by ehall »

dgrossato wrote:OK, fixes now script goes like this:

Code: Select all

/usr/bin/php ./scripts/ipmi_sensors.php TEMPERATURE "", "", "", query sensorname
You need to specify the hostname ("" will be treated as the hostname in the example above). You do not need to specify the "" pairs for username or password either, since they will be provided as empty strings if no SNMPv1/v2 username or password are provided.

Just use something like:

Code: Select all

/usr/bin/php ./scripts/ipmi_sensors.php TEMPERATURE localhost, , , query sensorname
That's all you need
koole
Posts: 1
Joined: Tue Mar 28, 2006 6:37 am

Post by koole »

php ipmi_sensors.php TEMPERATURE ip_address, , , query sensorname

This returns nothing to me. It queries something, because it takes about 15 seconds to run over (normal ipmitool sdr query time...). I dont know anymore what kind of query to do!

But hey Ehall!

There is a feature to use local cache file for ipmitool sdr queries.

man ipmitool:

-S <sdr_cache_file>
Use local file for remote SDR cache. Using a local SDR cache can drasti-
cally increase performance for commands that require knowledge of the
entire SDR to perform their function. Local SDR cache from a remote sys-
tem can be created with the sdr dump command.

That increase performance of ipmitool dramatically indeed!
msubieta
Posts: 1
Joined: Wed Oct 25, 2006 10:49 am

Data Query XML data definitions missing

Post by msubieta »

I just tried the scripts and I have followed the rather obscure directions on how to install this plugin. However, I still get an empty graph. I am able to get information using the ipmi_sensor.php script, but I cannot make the data available to rrdtool, or get stored in the cacti database for all that matters. I read that the data query must be entered, but I do not know what the xml data definitions file is, or how I will enter the username and password into the query so that it will work.

I have 64 servers I need to constantly monitor temperature-wise, and so far this is the best way I found. I also found something about lm_sensors, but again the documentation on how to implement this is very limited. I will be more than happy to write the steps necessary to get this thing up and running if I only had enough information to do it.
Blackblade
Posts: 4
Joined: Thu Feb 01, 2007 8:09 am

Re: Data Query XML data definitions missing

Post by Blackblade »

Hi all,

I have similar problems. I've tried to use the script and xml-files, ehall has build, but I think, there are several additional steps to do, which I don't understand.

As far as I understood, the files from ehal provides data and graph templates and a script to collect the data.
The script is working without problems. So I tried to create the cacti graphs.

To do this, I need the "appropriate data query" for the host. This data query is not in the zip-file and i have no idea, how to create it manually.

Anybody here, who can give two beginners in cacti the needed help, to get this working?

Many thanks in advance,

Michael
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Post by ehall »

It doesn't appear that the original tar file had all of the templates. Don't know how it went so long without being noticed, but all of the dependencies were supposed to have been included. Anyway, I uploaded a new one that should have everything.

All of the XML files are exported from cacti 0.8.6i. Import them all, starting with the data templates, then the data queries, then finally the graphs.

Copy the .php script to your cacti scripts directory.

IPMI uses authentication, but cacti does not provide any means to specify additional variables to the script-query interface, so you have to figure out some kind of way around this.

One option (what I use here) is to create a null IPMI operator account on your machines. You can do this with "ipmitool user enable" (with no username) and then use ipmitool to further tweak the privileges and whatnot. If the script does not receive any username parameters (see bottom of post) then it will use the special NULL username and password to perform the queries.

Another option is to change the script source code. By default, if no username is provided on the command line, then the script will use the special NULL username (referred to above) with a pair of empty quote marks. You can change this to use another username if you want, so that the absence of a username and password will cause the script to use the username and password that you want.

The username code block is here:

Code: Select all

        #
        # check for username and use NULL if not provided
        #
        if ($username != "") {

                $cmdtool = $cmdtool . " -U $username";
        }

        else {
                $cmdtool = $cmdtool . " -U \"\"";
        }
You'll need to do the same for password.

It is possible to pass a username and password on the command-line, but that comes from overloading the SNMPv3 fields in cacti, and that has very limited applicability in most cases. You would need to create a host definition that uses SNMPv3, make sure that the host responds to pings (and there may be some other cacti tweaks like not probing SNMP), etc. If your host uses IPMI on a different IP address than the operating system uses (pretty common) then this can be a feasible method, and I've used it here myself.

Generally speaking the absolute simplest thing to do is use the ipmisensors module for lm_sensors, and get the data from net-snmp lmsensors hooks. This script is really for people that need to use IPMI in particular. IPMI is hard and ugly, I know.
Blackblade
Posts: 4
Joined: Thu Feb 01, 2007 8:09 am

Post by Blackblade »

Hello,

thanks for the quick reply. The new archive takes me a step further, but there are the "<path_cacti>/resource/script_queries/ipmi_*.xml" files still missing. I think
Do i have to create them manually? If yes, can you give me a hint, how?

Bye, Michael
PowerSp00n
Posts: 1
Joined: Thu Feb 22, 2007 9:42 am

Post by PowerSp00n »

Blackblade wrote:Hello,
but there are the "<path_cacti>/resource/script_queries/ipmi_*.xml" files still missing. I think
Do i have to create them manually? If yes, can you give me a hint, how?
Same here. Also the file cacti_graph_template_sensors_ipmi_fan_sensors_8x.xml returns an error after importing it:

Code: Select all

Cacti has imported the following items:

GPRINT Preset
[success] Exact Numbers [update]

Graph Template
[success] Sensors - IPMI - Fan Sensors (8x) [update]
   + Found Dependency: (GPRINT Preset) Exact Numbers
   + Unmet Dependency: (Data Template Item)
   + Unmet Dependency: (Data Template Item)
   + Unmet Dependency: (Data Template Item)
   + Unmet Dependency: (Data Template Item) 
etc...
Blackblade
Posts: 4
Joined: Thu Feb 01, 2007 8:09 am

Post by Blackblade »

Hi,

long time no news :). Perhaps anybody can give us a hint, how to handle the missing xml-files?

Bye, Michael
ehall
Cacti User
Posts: 246
Joined: Fri Dec 09, 2005 3:42 pm

Post by ehall »

A new tarball was uploaded that should have everything, and a note was added to describe the missing GPRINT Preset. I guess cacti doesn't include GPRINT definitions in the exports...
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests