Glen Pitt-Pladdy :: Blog
LM Sensors stats on Cacti (via SNMP)
Following on from the basics of SNMP I did previously, this article now adds the next set of SNMP extension scripts, config, and Cacti templates to monitor LM Sensors data from Motherboard Sensors.
Most PC Motherboards these days contain an array of sensors and data captured from the system. This may include Motherboard Voltages, Temperatures, Fan speeds among other things.
The Linux package "lmsensors" provides tools to interrogate many popular Motherboard sensors chips and extract useful data from them. This article can't cover the particular setup required for your Motherboard sensor chip. There is plenty of docs and example config around to help you get the LM Sensors package configured.
Where we need to get to for this article is being able to execute the "sensors" command as a regular user and getting back a load of correct data from different sensors on the Motherboard.
Sensors over SNMP
Fortunately as sensors are available to unprivileged users the acrobatics discussed previously are not needed to get this data into snmpd. A bunch of extension scripts and some config is all that is needed.
I have made all my sensor scripts for the Motherboard I monitor available below. As each Motherboard is different and provides different sensors, you will need to adapt these scripts to your particular motherboard. They are basically shell scripts that use grep, and sed to extract the parameters we want from the "sensors" command.
I place these sensors-* scripts (make it executable first: chmod +x sensors-*) in /etc/snmp
As mentioned, you will need to adapt the scripts for the output of your sensors chips and config.
In /etc/snmp/snmpd.conf add the following lines:
extend sensortemps /etc/snmp/sensors-temps
Many Motherboards provide other parameters which you could also monitor by adapting these scripts.
Once you have added all this in you can test these by running the scripts from the command line, and via SNMP by appending the appropriate SNMP OID to the "snmpwalk" commands shown previously.
I have generated some basic Cacti Templates for my sensors outputs. You will have to adapt these Graph Templates and the corresponding Data Source Templates to match your sensors outputs.
Simply import the template cacti_host_template_lm_sensors_parameters.xml, modify them as needed, and add the graphs you want to the appropriate device graphs in Cacti. It should just work if your SNMP is working correctly for that device (ensure other SNMP parameters are working for that device).
Graph Screen Shots
One person had pointed out that there has been some problems on some versions of Cacti with importing the templates. The template was generated with version 0.8.7b (from Debain Lenny).
The problem manifests it's self as "Cacti version does not exist" error, and appears to be cured by adding in this version, although in my version the file is actually global_arrays.php
The relevant array from my global_arrays.php / config_array.php:
$hash_version_codes = array(
Copyright Glen Pitt-Pladdy 2008-2017