Re: Exclude invalid sensors from the sensors MIB
On 2015/11/17 11:47, Gerhard Roth wrote: > Sensors marked as invalid should be excluded by snmpd(8) from the sensors > MIB just as sysctl(8) excludes them from the 'hw.sensors' tree. Agreed - any OKs to commit? After: $ snmptable -v2c -c public 127.0.0.1 sensorTable SNMP table: OPENBSD-SENSORS-MIB::sensorTable sensorIndexsensorDescr sensorType sensorDevice sensorValue sensorUnits sensorStatus 1"temp0" temperature "cpu0" "36.00" "degC" unspecified 2 "zone temperature" temperature"acpitz0" "27.80" "degC" unspecified 3 "zone temperature" temperature"acpitz1" "29.80" "degC" unspecified 4"temp0" temperature"sdtemp0" "34.25" "degC" unspecified 5"temp0" temperature"sdtemp1" "33.50" "degC" unspecified 6"inner" temperature "ugold0" "21.37" "degC" unspecified 7 "sd3" drive "softraid0""online" "" ok Before: $ snmptable -v2c -c public 127.0.0.1 sensorTable SNMP table: OPENBSD-SENSORS-MIB::sensorTable sensorIndex sensorDescr sensorType sensorDevice sensorValue sensorUnits sensorStatus 1 "temp0" temperature "cpu0" "38.00" "degC" unspecified 2 "zone temperature" temperature"acpitz0" "27.80" "degC" unspecified 3 "zone temperature" temperature"acpitz1" "29.80" "degC" unspecified 4"voltage" voltsdc "acpibat0" "0.00" "V DC" unspecified 5"current voltage" voltsdc "acpibat0" "0.00" "V DC" unspecified 6 "rate" power "acpibat0" "0.00" "W" unspecified 7 "last full capacity"watthour "acpibat0" "0.00" "Wh" unspecified 8 "warning capacity"watthour "acpibat0" "0.00" "Wh" unspecified 9 "low capacity"watthour "acpibat0" "0.00" "Wh" unspecified 10 "remaining capacity"watthour "acpibat0" "0.00" "Wh" unspecified 11"design capacity"watthour "acpibat0" "0.00" "Wh" unspecified 12"battery removed" raw "acpibat0" "0" "" unspecified 13"voltage" voltsdc "acpibat1" "0.00" "V DC" unspecified 14"current voltage" voltsdc "acpibat1" "0.00" "V DC" unspecified 15 "rate" power "acpibat1" "0.00" "W" unspecified 16 "last full capacity"watthour "acpibat1" "0.00" "Wh" unspecified 17 "warning capacity"watthour "acpibat1" "0.00" "Wh" unspecified 18 "low capacity"watthour "acpibat1" "0.00" "Wh" unspecified 19 "remaining capacity"watthour "acpibat1" "0.00" "Wh" unspecified 20"design capacity"watthour "acpibat1" "0.00" "Wh" unspecified 21"battery removed" raw "acpibat1" "0" "" unspecified 22"voltage" voltsdc "acpibat2" "0.00" "V DC" unspecified 23"current voltage" voltsdc "acpibat2" "0.00" "V DC" unspecified 24 "rate" power "acpibat2" "0.00" "W" unspecified 25 "last full capacity"watthour "acpibat2" "0.00" "Wh" unspecified 26 "warning capacity"watthour "acpibat2" "0.00" "Wh" unspecified 27 "low capacity"watthour "acpibat2" "0.00" "Wh" unspecified 28 "remaining capacity"watthour "acpibat2" "0.00" "Wh" unspecified 29"design capacity"watthour "acpibat2" "0.00" "Wh" unspecified 30"battery removed" raw "acpibat2" "0" "" unspecified 31 "temp0" temperature"sdtemp0" "34.50" "degC" unspecified 32 "temp0" temperature"sdtemp1" "33.75" "degC" unspecified 33 "inner" temperature "ugold0" "21.25" "degC" unspecified 34"sd3" drive "softraid0""online" "" ok
Re: Exclude invalid sensors from the sensors MIB
ok Stuart Henderson(st...@openbsd.org) on 2015.11.17 11:33:50 +: > On 2015/11/17 11:47, Gerhard Roth wrote: > > Sensors marked as invalid should be excluded by snmpd(8) from the sensors > > MIB just as sysctl(8) excludes them from the 'hw.sensors' tree. > > Agreed - any OKs to commit? > > After: > > $ snmptable -v2c -c public 127.0.0.1 sensorTable > SNMP table: OPENBSD-SENSORS-MIB::sensorTable > > sensorIndexsensorDescr sensorType sensorDevice sensorValue > sensorUnits sensorStatus >1"temp0" temperature "cpu0" "36.00" > "degC" unspecified >2 "zone temperature" temperature"acpitz0" "27.80" > "degC" unspecified >3 "zone temperature" temperature"acpitz1" "29.80" > "degC" unspecified >4"temp0" temperature"sdtemp0" "34.25" > "degC" unspecified >5"temp0" temperature"sdtemp1" "33.50" > "degC" unspecified >6"inner" temperature "ugold0" "21.37" > "degC" unspecified >7 "sd3" drive "softraid0""online" > "" ok > > Before: > > $ snmptable -v2c -c public 127.0.0.1 sensorTable > SNMP table: OPENBSD-SENSORS-MIB::sensorTable > > sensorIndex sensorDescr sensorType sensorDevice sensorValue > sensorUnits sensorStatus >1 "temp0" temperature "cpu0" "38.00" > "degC" unspecified >2 "zone temperature" temperature"acpitz0" "27.80" > "degC" unspecified >3 "zone temperature" temperature"acpitz1" "29.80" > "degC" unspecified >4"voltage" voltsdc "acpibat0" "0.00" > "V DC" unspecified >5"current voltage" voltsdc "acpibat0" "0.00" > "V DC" unspecified >6 "rate" power "acpibat0" "0.00" > "W" unspecified >7 "last full capacity"watthour "acpibat0" "0.00" > "Wh" unspecified >8 "warning capacity"watthour "acpibat0" "0.00" > "Wh" unspecified >9 "low capacity"watthour "acpibat0" "0.00" > "Wh" unspecified > 10 "remaining capacity"watthour "acpibat0" "0.00" > "Wh" unspecified > 11"design capacity"watthour "acpibat0" "0.00" > "Wh" unspecified > 12"battery removed" raw "acpibat0" "0" > "" unspecified > 13"voltage" voltsdc "acpibat1" "0.00" > "V DC" unspecified > 14"current voltage" voltsdc "acpibat1" "0.00" > "V DC" unspecified > 15 "rate" power "acpibat1" "0.00" > "W" unspecified > 16 "last full capacity"watthour "acpibat1" "0.00" > "Wh" unspecified > 17 "warning capacity"watthour "acpibat1" "0.00" > "Wh" unspecified > 18 "low capacity"watthour "acpibat1" "0.00" > "Wh" unspecified > 19 "remaining capacity"watthour "acpibat1" "0.00" > "Wh" unspecified > 20"design capacity"watthour "acpibat1" "0.00" > "Wh" unspecified > 21"battery removed" raw "acpibat1" "0" > "" unspecified > 22"voltage" voltsdc "acpibat2" "0.00" > "V DC" unspecified > 23"current voltage" voltsdc "acpibat2" "0.00" > "V DC" unspecified > 24 "rate" power "acpibat2" "0.00" > "W" unspecified > 25 "last full capacity"watthour "acpibat2" "0.00" > "Wh" unspecified > 26 "warning capacity"watthour "acpibat2" "0.00" > "Wh" unspecified > 27 "low capacity"watthour "acpibat2" "0.00" > "Wh" unspecified > 28 "remaining capacity"watthour "acpibat2" "0.00" > "Wh" unspecified > 29"design capacity"watthour "acpibat2" "0.00" > "Wh" unspecified > 30"battery removed" raw "acpibat2" "0" > "" unspecified > 31 "temp0" temperature"sdtemp0" "34.50" > "degC" unspecified > 32 "temp0" temperature"sdtemp1" "33.75" > "degC" unspecified > 33 "inner" temperature "ugold0" "21.25" > "degC" unspecified > 34"sd3" drive "softraid0""online" > "" ok > --
Exclude invalid sensors from the sensors MIB
Sensors marked as invalid should be excluded by snmpd(8) from the sensors MIB just as sysctl(8) excludes them from the 'hw.sensors' tree. Gerhard Index: usr.sbin/snmpd/mib.c === RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v retrieving revision 1.79 diff -u -p -u -p -r1.79 mib.c --- usr.sbin/snmpd/mib.c8 Oct 2015 08:29:21 - 1.79 +++ usr.sbin/snmpd/mib.c17 Nov 2015 10:39:31 - @@ -2556,7 +2556,7 @@ mib_sensors(struct oid *oid, struct ber_ } for (j = 0; j < SENSOR_MAX_TYPES; j++) { mib[3] = j; - for (k = 0; k < sensordev.maxnumt[j]; k++, n++) { + for (k = 0; k < sensordev.maxnumt[j]; k++) { mib[4] = k; if (sysctl(mib, 5, , , NULL, 0) == -1) { @@ -2566,8 +2566,11 @@ mib_sensors(struct oid *oid, struct ber_ break; return (-1); } + if (sensor.flags & SENSOR_FINVALID) + continue; if (n == idx) goto found; + n++; } } }