Graphing your servers motherboard temperature and fan RPM speeds
rene — Thu, 04/16/2009 - 07:30
Cacti, the "complete network graphing solution", is a powerful web application that provides rrdtool graphing templates and data collection methods. Think web based system graphing and collection platform.
There is a small learning curve in creating advanced graphs, though once you flatten this curve you're able to harness the power of Cacti to do fancy things like graphing your motherboard temperature and fan RPM speeds.
Heres how
Install and configure lm-sensorslm-sensors is the hardware monitoring tool that will provide essential information on your hardware health such as motherboard temperature, CPU core temperature and fan RPM speed. Install and configuring in Ubuntu is as easy as
$ sudo apt-get install lm-sensors $ sudo sensors-detect
A series of questions will be asked by sensors-detect though choosing the default answers should hopefully work. If not, its best to consult the lm-sensors installation wizard guide on the lm-sensors wiki.
Install cactiInstalling cacti should be fairly straight forward too within Ubuntu. Your mileage may vary with other distributions but with Debian based systems such as Ubuntu run
$ sudo apt-get install cacti
If you have any problems configuring Cacti, /usr/share/doc/cacti/ if your friendly document directory that may provide you with some help.
Install and test a Cacti collection script You will be passing information to Cacti via a script which needs to use the standard cacti data input template defined in the cacti manual.<fieldname_1>:<value_1> <fieldname_2>:<value_2> ... <fieldname_n>:<value_n>
Ive created a perl script to filter out the useful stuff outputted from the 'sensors' application. It will output information in the format cacti expects. Below is an example of the output
$ /usr/local/bin/sensors_cacti fan1:1266 fan2:0 fan3:1973 fan4:1295 in0:1.04 in1:1.89 in2:3.26 ..
You can download this script called sensors_cacti here
Feel free to hack some of your own code or use mine though be sure that the output conforms to what cacti expects. Cacti Data Input Method Once you log into cacti, go to Data Input Methods->Add to create a new data input method which will have following attributesName: lm_sensors
Input Type: Script/Command
Input String: /usr/local/bin/sensors_cacti
The 'Input String' is the path to the script that will generate the output cacti will use to fill its rrdtool databases. The script will need to be executable by the Web server system account on your box.
The 'Input Fields' section stays blank though the 'Output Fields' section will need to be filled out. The 'Output Fields' are the fields that your script will output. Cacti needs to know what these fields are so it can create and update its rrdtool databases based on the values for these fields. Also the 'Name' of the fields needs to match the field name which your script outputs. Im capturing and graphing core CPU temperature, fan RPM speed and motherboard temperature so the output of the script would befan1:1266 fan2:0 fan3:1979 fan4:1293 in0:1.06 in1:1.89 ..Data Template Go to Data template->Add and create a template with the following attributes
Data Templates
Name: lm_sensors
Data Source
Name: |host_description| - lm sensors
Data Input Method: lm_sensors
You will then need to create a 'Data Source Item' for each lm-sensors label (ie; in1,fan1). Ive created 21 different data sources for the Data Template that will hold data for various temperatures and RPM speeds of my motherboard so this part is time consuming.
An example of a Data Source Items attributes for the lm-sensors label fan1 are
Internal Data Source Name: fan1
Minimum Value: 0
Maximum Value: 0
Data Source Type: GAUGE
Heartbeat: 600
Output Field: fan1 - fan1
Use these attributes for the motherboard temperature Graph Template
Template
Name: Motherboard Temperature
Graph Template
Title: |host_description| - Motherboard Temperature
Vertical Label: Celsius
Click Create->Graph Template Items->Add.
Graph Template Items
Data Source: lm_sensors - (temp1)
Color: FF0000
Graph Item Type: AREA
Value: Celcius
Text Format: temp1
Create another Graph Template Items for temp2 and any other lm-sensors temp labels you have. You can add average, minimum and maximum values to your graph by creating a GPRINT graph item type using the appropriate CF types.
Create the graph! After all this work we can now create a real graph by going to Graph Management->AddGraph Template Selection
Selected Graph Template: Motherboard Temperature
Host: Localhost (127.0.0.1)
Supplemental Graph Template Data
Data Source [temp1]: Localhost - lm_sensors (temp1)
Data Source [temp2]: Localhost - lm_sensors (temp2)
Click Save and allow cacti to populate the rrd databases with a bit of data which can be graphed. This can usually take up to 30 minutes as the cacti rrd poller runs every 5 minutes from within cron.
You can find my data and graph templates in xml here and here which can be imported into Cacti.































