|
|
b5ae06 |
Bug 967871 - net-snmp does not display correct lm_sensors sensor data / missing CPU cores
|
|
|
b5ae06 |
|
|
|
b5ae06 |
commit e886f5eb9701851ad6948583156bfd59fcb6110f
|
|
|
b5ae06 |
Author: Jan Safranek <jsafranek@users.sourceforge.net>
|
|
|
b5ae06 |
Date: Wed Feb 25 09:30:24 2015 +0100
|
|
|
b5ae06 |
|
|
|
b5ae06 |
CHANGES: snmpd: fixed lm_sensors not reporting sensors with duplicate names.
|
|
|
b5ae06 |
|
|
|
b5ae06 |
Some systems report two or more sensors with the same name.
|
|
|
b5ae06 |
This patch adds support for reporting of all these duplicate
|
|
|
b5ae06 |
sensor names.
|
|
|
b5ae06 |
|
|
|
b5ae06 |
Before the patch, these sensors were reported:
|
|
|
b5ae06 |
> lmTempSensorsDevice.2 = STRING: Core 0
|
|
|
b5ae06 |
|
|
|
b5ae06 |
After the patch, new sensors appear with a prefix:
|
|
|
b5ae06 |
> lmTempSensorsDevice.2 = STRING: Core 0
|
|
|
b5ae06 |
> lmTempSensorsDevice.6 = STRING: coretemp-isa-0004:Core 0
|
|
|
b5ae06 |
|
|
|
b5ae06 |
This approach keeps backward compatibility (applications used to 'Core 0'
|
|
|
b5ae06 |
will keep workig, while it adds new sensorscto the table (with a prefix).
|
|
|
b5ae06 |
|
|
|
b5ae06 |
diff --git a/agent/mibgroup/hardware/sensors/lmsensors_v3.c b/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
|
|
b5ae06 |
index 60af9e6..1de7c68 100644
|
|
|
b5ae06 |
--- a/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
|
|
b5ae06 |
+++ b/agent/mibgroup/hardware/sensors/lmsensors_v3.c
|
|
|
b5ae06 |
@@ -86,7 +86,28 @@ netsnmp_sensor_arch_load(netsnmp_cache *cache, void *vp) {
|
|
|
b5ae06 |
* (inserting it in the appropriate sub-containers)
|
|
|
b5ae06 |
*/
|
|
|
b5ae06 |
sp = sensor_by_name( label, type );
|
|
|
b5ae06 |
- if ( sp ) {
|
|
|
b5ae06 |
+ if ( sp && sp->flags & NETSNMP_SENSOR_FLAG_ACTIVE) {
|
|
|
b5ae06 |
+ /*
|
|
|
b5ae06 |
+ * Some HW does not have unique sensors labels.
|
|
|
b5ae06 |
+ * We already have a sensor with this label, thus
|
|
|
b5ae06 |
+ * try to create unique label by adding chip-name prefix
|
|
|
b5ae06 |
+ * and try again.
|
|
|
b5ae06 |
+ */
|
|
|
b5ae06 |
+ char chip_name[64];
|
|
|
b5ae06 |
+ char new_label[128];
|
|
|
b5ae06 |
+ int ret;
|
|
|
b5ae06 |
+ DEBUGMSGTL(("sensors:arch:detail", "Already know label %s, adding prefix\n", label));
|
|
|
b5ae06 |
+ ret = sensors_snprintf_chip_name(chip_name, sizeof(chip_name), chip);
|
|
|
b5ae06 |
+ if (ret < 0) {
|
|
|
b5ae06 |
+ DEBUGMSGTL(("sensors:arch:detail", "Can't get chip name for label %s\n", label));
|
|
|
b5ae06 |
+ free(label);
|
|
|
b5ae06 |
+ continue;
|
|
|
b5ae06 |
+ }
|
|
|
b5ae06 |
+ snprintf(new_label, sizeof(new_label), "%s:%s", chip_name, label);
|
|
|
b5ae06 |
+ DEBUGMSGTL(("sensors:arch:detail", "New label: %s\n", new_label));
|
|
|
b5ae06 |
+ sp = sensor_by_name( new_label, type );
|
|
|
b5ae06 |
+ }
|
|
|
b5ae06 |
+ if (sp) {
|
|
|
b5ae06 |
sp->value = val;
|
|
|
b5ae06 |
sp->flags|= NETSNMP_SENSOR_FLAG_ACTIVE;
|
|
|
b5ae06 |
}
|