diff --git a/NYMNETWORKS-MIB.txt b/NYMNETWORKS-MIB.txt index 37b2fad..88c5f75 100644 --- a/NYMNETWORKS-MIB.txt +++ b/NYMNETWORKS-MIB.txt @@ -9,6 +9,7 @@ nymnetworks OBJECT IDENTIFIER ::= {enterprises 25359} zfs OBJECT IDENTIFIER ::= {nymnetworks 1} ipmi OBJECT IDENTIFIER ::= {nymnetworks 2} +ups OBJECT IDENTIFIER ::= {nymnetworks 3} fs OBJECT IDENTIFIER ::= {zfs 1} @@ -184,5 +185,86 @@ tempSensorValue OBJECT-TYPE "The current value of the designated temperature sensor." ::= {temperature 2} + +upsId OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The UPS identifier." + ::= {ups 1} + +upsModel OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The UPS model name." + ::= {ups 2} + +upsManufacturer OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The UPS manufacturer name." + ::= {ups 3} + +upsSerial OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The UPS serial number." + ::= {ups 4} + +upsBatteryChargePercent OBJECT-TYPE + SYNTAX GAUGE + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The current battery charge in percent." + ::= {ups 5} + +upsBatteryRuntimeSec OBJECT-TYPE + SYNTAX GAUGE + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The current remaining runtime in seconds." + ::= {ups 6} + +upsBatteryVoltagedV OBJECT-TYPE + SYNTAX GAUGE + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The current battery voltage in dV." + ::= {ups 7} + +upsBatteryNominalVoltagedV OBJECT-TYPE + SYNTAX GAUGE + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The nominal battery voltage in dV." + ::= {ups 8} + +upsBatteryType OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The battery type." + ::= {ups 9} + +upsStatus OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "The current UPS status string." + ::= {ups 10} + END diff --git a/README.md b/README.md index 36022ef..101e21a 100644 --- a/README.md +++ b/README.md @@ -26,24 +26,42 @@ When deployed, it provides the following additional information: NYMNETWORKS-MIB::zfsReadKB.0 = Counter32: 765171103 NYMNETWORKS-MIB::zfsReaddirKB.0 = Counter32: 6260406 NYMNETWORKS-MIB::zfsWriteKB.0 = Counter32: 577324153 - NYMNETWORKS-MIB::tempSensorName.0 = STRING: "System Temp" - NYMNETWORKS-MIB::tempSensorValue.0 = Gauge32: 20 With this information, you can graph ZFS ARC size and hit rate, ZFS IO rate and ZFS L2ARC hit rate and IO rate. Have a look in the MIB or in the source for -more detailed descriptions of the individual variables. +more detailed descriptions of the individual variables. If you add the `ipmi-snmp` +script, you'll get a basic temperature reading: + + NYMNETWORKS-MIB::tempSensorName.0 = STRING: "System Temp" + NYMNETWORKS-MIB::tempSensorValue.0 = Gauge32: 20 + +If you have a NUT installation and add the `nut-snmp` script, youll get some +basic UPS stats: + + NYMNETWORKS-MIB::upsId.1 = STRING: "smartups" + NYMNETWORKS-MIB::upsModel.1 = STRING: "Smart-UPS 750" + NYMNETWORKS-MIB::upsManufacturer.1 = STRING: "American Power Conversion" + NYMNETWORKS-MIB::upsSerial.1 = STRING: "AS1141221798" + NYMNETWORKS-MIB::upsBatteryChargePercent.1 = Gauge32: 100 + NYMNETWORKS-MIB::upsBatteryRuntimeSec.1 = Gauge32: 2340 + NYMNETWORKS-MIB::upsBatteryVoltagedV.1 = Gauge32: 275 + NYMNETWORKS-MIB::upsBatteryNominalVoltagedV.1 = Gauge32: 240 + NYMNETWORKS-MIB::upsBatteryType.1 = STRING: "PbAc" + NYMNETWORKS-MIB::upsStatus.1 = STRING: "OL" To use, drop the scripts - ipmi-snmp snmpresponse.py zfs-snmp + ipmi-snmp + nut-snmp in for example `/usr/local/bin`, add the following to `/etc/net-snmp/snmp/snmpd.conf`: pass .1.3.6.1.4.1.25359.1 /usr/local/bin/zfs-snmp - pass .1.3.6.1.4.1.25359.2 /usr/local/bin/ipmi-snmp + pass .1.3.6.1.4.1.25359.2 /usr/local/bin/ipmi-snmp # Optional, for IPMI + pass .1.3.6.1.4.1.25359.3 /usr/local/bin/nut-snmp # Optional, for NUT/UPS and `svcadm restart net-snmp`. If you don't already use the net-snmp service you will need to set community etc at the top of the file and `svcadm enable net-snmp`. diff --git a/nut-snmp b/nut-snmp new file mode 100755 index 0000000..ec971ea --- /dev/null +++ b/nut-snmp @@ -0,0 +1,42 @@ +#!/usr/bin/python + +BASE_OID = '.1.3.6.1.4.1.25359.3' +UPSC = '/usr/local/ups/bin/upsc' + +import sys, commands, re, snmpresponse + +def list_upses(): + return commands.getoutput("%s -l"%UPSC).split("\n") + +def upsc_val(oid, ups, value): + line = commands.getoutput("%s %s | grep %s | head -1"%(UPSC, ups, value)) + fields = line.split(':') + val = fields[1].strip() + if re.match('^[0-9]+$', val): + return ('gauge', int(val)) + elif re.match('^[0-9.]+$', val): + return ('gauge', int(float(val) * 10)) + else: + return ('string', val) + +result = [ ] + +i = 1 +for ups in list_upses(): + result.append((BASE_OID + '.1.' + str(i), ('string', ups))) + result.append((BASE_OID + '.2.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'device.model'))) + result.append((BASE_OID + '.3.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'device.mfr'))) + result.append((BASE_OID + '.4.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'device.serial'))) + result.append((BASE_OID + '.5.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'battery.charge'))) + result.append((BASE_OID + '.6.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'battery.runtime'))) + result.append((BASE_OID + '.7.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'battery.voltage'))) + result.append((BASE_OID + '.8.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'battery.voltage.nominal'))) + result.append((BASE_OID + '.9.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'battery.type'))) + result.append((BASE_OID + '.10.' + str(i), lambda oid, ups=ups: upsc_val(oid, ups, 'ups.status'))) + i += 1 + +operation = sys.argv[1] +req_oid = sys.argv[2] + +snmpresponse.respond_to(operation, req_oid, result) +