I am writing a cmk script to check the status of fans in Baystack switches. In order to convert the fan “index” number returned from the snmp_info oids into “Chassis # Fan #” I have to know the “Encode Factor”. This encode factor is an oid number and check_mk appears to only do snmpwalk.
What I need to get is the output from an snmpget in my script. In other words the line below “ s5ChasGrpEncodeFactor = int(10)” should be the result of an snmpget of this oid# “.1.3.6.1.4.1.45.1.6.3.2.1.1.8.6”
.iso.org.dod.internet.private.enterprises.synoptics.products.series5000.s5Chassis.s5ChasGrp.s5ChasGrpTable.s5ChasGrpEntry.s5ChasGrpEncodeFactor.6 = 5
This output could be a “5” or a “10”, depending on the switch, but I can’t figure out how to retrieve that value.
Here is what I have that works, if I input a hard coded “integer” in place of the variable that I need:
#!/usr/bin/python
-- encoding: utf-8; py-indent-offset: 4 --
···
def inventory_my5510fan(info):
inventory = []
for line in info:
s5ChasComDescr = line[1]
s5ChasGrpEncodeFactor = int(10)
s5ChasComIndx = int(line[0])
Chassis_num = int(s5ChasComIndx/s5ChasGrpEncodeFactor)
s5ChasComOperState = line[2]
Fan_num = int(s5ChasComIndx%s5ChasGrpEncodeFactor +1)
Fan_location = “Chassis %s Fan %s” % (Chassis_num, Fan_num)
inventory.append( (Fan_location, None,) )
return inventory
def check_my5510fan(item, _no_params, info):
for line in info:
s5ChasComDescr = line[1]
s5ChasGrpEncodeFactor = int(10)
s5ChasComIndx = int(line[0])
Chassis_num = int(s5ChasComIndx/s5ChasGrpEncodeFactor)
s5ChasComOperState = line[2]
Fan_num = int(s5ChasComIndx%s5ChasGrpEncodeFactor +1)
Fan_location = “Chassis %s Fan %s” % (Chassis_num, Fan_num)
if Fan_location == item:
if s5ChasComOperState == “5” and s5ChasComDescr == “Internal Fan”:
return (0, “OK - state is normal(” + s5ChasComOperState + “)”)
if s5ChasComOperState == “8” and s5ChasComDescr == “Internal Fan”:
return (1, “WARNING - State is warning(” + s5ChasComOperState + “)”)
else:
return (2, "CRITICAL - " + s5ChasComDescr + " state is " + s5ChasComOperState)
return (3, “UNKNOWN - Fan not found”+ s5ChasComOperState)
check_info[“my5510fan”] = \
(check_my5510fan, “Fan %s”, 0, inventory_my5510fan)
checkgroup_of[‘my5510fan’] = “Fan Group”
snmp_info[‘my5510fan’] = ( ‘.1.3.6.1.4.1.45.1.6.3.3.1.1’, [
‘2.6’, # s5ChasComIndx
‘5.6’, # s5ChasComDescr
‘10.6’, # s5ChasComOperState
])
snmp_scan_functions[‘my5510fan’] = \
lambda oid: oid(’.1.3.6.1.2.1.1.2.0’).startswith(’.1.3.6.1.4.1.45’)