Linux
banshee/linux-collection/linux/snmp/
temperatures
Hardware temperatures of a Linux host by SNMP, from the lm_sensors sensors that net-snmp serves.
par banshee1 installation2 versions
v2Dernière
Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.
// The temperatures of a Linux host, by SNMP, from lmTempSensorsTable (LM-SENSORS-MIB), which net-snmp
// serves when it is built with lm_sensors and the machine has sensors: a virtual machine has none. With no
// sensor read, the collector stops and says so, rather than stay green on nothing.
// The temperature reads in thousandths of a degree: lmTempSensorsTemperature, signed, when the agent
// serves it, otherwise the older lmTempSensorsValue. Two sensors of the same name ("temp1" on two chips)
// each keep their own: the second carries its index.
need('protocol:snmp');
per('sensor', 'Sensors');
output('temperature', 'number', array('label' => 'Temperature', 'unit' => '°C', 'per' => 'sensor'));
watch.above('hot', 'High temperature', 'temperature', array('warning' => 80, 'critical' => 95, 'for' => '3 runs'));
// lmTempSensorsTable, by lmTempSensorsIndex: lmTempSensorsDevice (the sensor's name), lmTempSensorsValue
// and lmTempSensorsTemperature.
$sensors = snmp.table(array(
'name' => '1.3.6.1.4.1.2021.13.16.2.1.2',
'value' => '1.3.6.1.4.1.2021.13.16.2.1.3',
'temperature' => '1.3.6.1.4.1.2021.13.16.2.1.4',
));
$read = 0;
$seen = array();
foreach ($sensors as $index => $row) {
$milli = list.get($row, 'temperature', list.get($row, 'value', ''));
if (!list.has($row, 'name') || $milli == '') {
continue;
}
$name = $row['name'];
if (list.has($seen, $name)) {
$name = $name . ' #' . $index;
}
$seen[$name] = true;
$read = $read + 1;
value('temperature', number.round($milli / 1000, 1), $name);
}
if ($read == 0) {
fail('misconfigured', 'The agent serves no temperature (lmTempSensorsTable, LM-SENSORS-MIB)',
'net-snmp built without lm_sensors, or a machine without sensors, such as a virtual machine.');
}