All of my problems has been resolved, posting the final script here.
switchcpu_default_levels = (80.0000, 90.0000)
def check_switchcpu(item, params, info):
data = ((str(info)).split("(")[1])
data1 = (data.split(")")[0]).strip().replace("%","")
util = float(data1)
infotext = "CPU utilization " + str(util)
warn, crit = params
perfdata = [("util", util, warn, crit, 0, 100)]
if util >= crit:
return (2, infotext + " (critical at %d%%)" % crit, perfdata)
elif util >= warn:
return (1, infotext + " (warning at %d%%)" % warn, perfdata)
else:
return (0, infotext, perfdata)
check_info['switchcpu'] = {
'check_function' : check_switchcpu,
'inventory_function' : lambda info: [(None, "switchcpu_default_levels")],
'service_description' : 'CPU utilization',
'snmp_info': ('.1.3.6.1.4.1.4526.11.1.1.4', ["9"]),
'snmp_scan_function' : lambda oid: True,
"group" : "cpu_utilization",
"has_perfdata" : True,
}