Difference between revisions of "Transforms - Nice Interface Events"
From Zenoss Wiki
Crouthamela (Talk | contribs) (Created page with "This converts interface utilization into a percentage and Kb, Mb, Gb, etc. raw amount based on link speed. <syntaxhighlight lang=python> #Transform interface usage into reada...") |
Crouthamela (Talk | contribs) m |
||
Line 48: | Line 48: | ||
break | break | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | [[Category:Transforms]] |
Revision as of 17:34, 18 November 2013
This converts interface utilization into a percentage and Kb, Mb, Gb, etc. raw amount based on link speed.
#Transform interface usage into readable format import re fs_id = device.prepId(evt.component) for f in device.os.interfaces(): if f.id != fs_id: continue # Extract the percent and utilization from the summary m = re.search("threshold of [^:]+: current value ([\d\.]+)", evt.message) if not m: continue currentusage = (float(m.group(1))) * 8 p = (currentusage / f.speed) * 100 evtKey = evt.eventKey # Whether Input or Output Traffic if evtKey == "ifInOctets_ifInOctets|high utilization" or evtKey == "ifHCInOctets_ifHCInOctets|high utilization": evtNewKey = "Input" elif evtKey == "ifOutOctets_ifOutOctets|high utilization" or evtKey == "ifHCOutOctets_ifHCOutOctets|high utilization": evtNewKey = "Output" # Check the speed to determine the appropriate conversion # Gbps utilization if currentusage > 1000000000: Usage = currentusage / 1000000000 evt.summary = "High Interface " + evtNewKey + " Utilization: Currently %3.0f%% used (%3.2f Gbps)" % (p, Usage) evt.message = evt.summary # Mbps utilization elif currentusage > 1000000: Usage = currentusage / 1000000 evt.summary = "High Interface " + evtNewKey + " Utilization: Currently %3.0f%% used (%3.2f Mbps)" % (p, Usage) evt.message = evt.summary # Kbps utilization elif currentusage > 1000: Usage = currentusage / 1000 evt.summary = "High Interface " + evtNewKey + " Utilization: Currently %3.0f%% used (%3.2f Kbps)" % (p, Usage) evt.message = evt.summary # bps utilization elif currentusage < 1000: Usage = currentusage evt.summary = "High Interface " + evtNewKey + " Utilization: Currently %3.0f%% used (%3.2f bps)" % (p, Usage) evt.message = evt.summary break