hi everyone,
been working on creating a check for digium switchvox and could use some help as my python-fu is terrible. I’m trying to create a check that inventories the different providers that are configured, their current state and latency with perfdata. I haven’t gotten to the perfdata portion just yet. So far I have a check that does inventory the providers but I can’t get the status to output correctly:
def list_split(length, number):
for i in range(0, len(length), number):
yield length[i:i+number]
def inventory_digium_providers(info):
info_split = list(list_split(info, 8))
import pprint ; pprint.pprint(info)
for id, type, name, host, account_id, cb_ext, latency, state in info_split:
yield str(name[0]), None
def check_digium_providers(item, _no_params, info):
info_split = list(list_split(info, 8))
for id, type, name, host, account_id, cb_ext, latency, state in info_split:
if state[0] == "ok" or state[0] == "registered":
yield 0, "Status: %s" % state[0]
check_info["digium_providers"] = {
"check_function" : check_digium_providers,
"inventory_function" : inventory_digium_providers,
"service_description" : "Provider %s",
"has_perfdata" : True,
"snmp_info": ( ".1.3.6.1.4.1.22736.10.2", ["3"] ),
"snmp_scan_function": lambda oid: oid(".1.3.6.1.4.1.22736.10.1.1") is not None
}
Basically this outputs the following:
OK - Status: ok, Status: registered
In this example, I have two providers, one shows as status ok and the other shows as registered in the switchvox console. Don’t know enough about python to know why these two outputs are getting combined.