Sorry but I don’t understand your way.
I have set the credentials in the properties of the host and need to access the properties in the python script of the check, witch is a customization of the original check_mk check sni_octopuse_trunks:
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.1 "OpenStage 30"
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.2 "OpenStage 30"
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.7 "P. O. T."
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.9 "S0 extension"
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.11 "S0 trunk: extern"
#.1.3.6.1.4.1.231.7.2.9.3.8.1.3.13 "<not configured>: extern"
#[...]
#.1.3.6.1.4.1.231.7.2.9.3.8.1.4.11 2
#.1.3.6.1.4.1.231.7.2.9.3.8.1.4.13 1
import netsnmp
import cmk_base.config as config
def inventory_siemenshipath_trunks(info):
trunkports = [ "S0 trunk:", "CorNet NQ Trunk:" ]
oidporttypes = netsnmp.VarList(netsnmp.Varbind('.1.3.6.1.4.1.231.7.2.9.3.8.1.3'))
porttypes = netsnmp.snmpwalk(oidporttypes, Version=2, DestHost=host_name(), Community=config.snmp_credentials_of(host_name()))
inventory = []
indexI = 0
while indexI < len(porttypes):
for port in trunkports:
porttype = porttypes[indexI]
if port in porttype:
oid = netsnmp.Varbind('.1.3.6.1.4.1.231.7.2.9.3.8.1.1.' + str(indexI+1))
portindex = netsnmp.snmpget(oid, Version=2, DestHost=host_name(), Community=config.snmp_credentials_of(host_name()))
oid = netsnmp.Varbind('.1.3.6.1.4.1.231.7.2.9.3.8.1.2.' + str(indexI+1))
cardindex = netsnmp.snmpget(oid, Version=2, DestHost=host_name(), Community=config.snmp_credentials_of(host_name()))
portdesc = "%s/%s/%s" % (cardindex[0], portindex[0], porttype)
inventory.append((portdesc, None))
indexI += 1
return inventory
def check_siemenshipath_trunks(item, _no_params, info):
perfdata = []
cardindex, portindex, porttype = item.split('/')
oid = netsnmp.Varbind('.1.3.6.1.4.1.231.7.2.9.3.8.1.4.' + portindex)
portstates = netsnmp.snmpget(oid, Version=2, DestHost=host_name(), Community=config.snmp_credentials_of(host_name()))
perfdata = [ ("Active", portstates[0], 1, 0, 0, 2) ]
if portstates[0] == "1":
return (2, "Port [%s] is inactive" % porttype, perfdata)
elif portstates[0] == "2":
return (0, "Port [%s] is active" % porttype, perfdata)
return (3, "UNKW - unknown data received from agent", perfdata)
check_info['sni_siemenshipath_trunks'] = {
'check_function' : check_siemenshipath_trunks,
'inventory_function' : inventory_siemenshipath_trunks,
'service_description': "Trunk %s",
"has_perfdata" : True,
'snmp_scan_function' : lambda oid: "agent for hipath" in \
oid(".1.3.6.1.2.1.1.1.0").lower(),
'snmp_info' : [ (".1.3.6.1.4.1.231.7.2.9.3.8.1.4.1", []), ]
}