#!/usr/bin/python factory_settings["juniper_cpu_default_levels"] = { 'levels' : (50.0, 60.0), } fruTypesCPU = ['PIC', 'FPC', 'Routing Engine'] def inventory_juniper_cpu(info): inventory = [] for line in info: for fru in fruTypesCPU: if line[0].startswith(fru): inventory.append((line[0], None)) return inventory def check_juniper_cpu(item, params, info): for cpu, utilization in info: if item == cpu: util = float(utilization) infotext = " - %2.1f%% Utilization" % util if "levels" in params: warn, crit = params["levels"] else: warn, crit = params perfdata = [("util", util, warn, crit, 0, 100)] if util >= crit: return (2, "CRIT" + infotext + " (critical at %d%%)" % crit, perfdata) elif util >= warn: return (1, "WARN" + infotext + " (warning at %d%%)" % warn, perfdata) else: return (0, "OK" + infotext, perfdata) return (3, "UNKNOWN") check_info["juniper_cpu"] = { "check_function" : check_juniper_cpu, "inventory_function" : inventory_juniper_cpu, "service_description" : "CPU Utilization: ", "has_perfdata" : True, "group" : "cpu_utilization", "snmp_scan_function" : lambda oid: "Juniper" in oid(".1.3.6.1.4.1.2636.3.1.2.0"), "snmp_info" : ( ".1.3.6.1.4.1.2636.3.1.13.1", [ 5, 8 ] ), "default_levels_variable" : "juniper_cpu_default_levels", }