Transforms - Nice Interface Events

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

This converts interface utilization into a percentage and Kb, Mb, Gb, etc. raw amount based on link speed.

Event Class: Perf > Interface

# Transform interface usage for /Perf/Interface threshold events into readable format
# Check if this actually is on an interface component with a speed attribute
if getattr(component, 'speed', None) is not None:
   # Extract the percent and utilization from the summary
   import re
   m ="threshold of [^:]+: current value ([\d\.]+)", evt.message)
   currentusage = (float( * 8
   # Convert to a percentage of speed. Like threshold, use default speed of 1e09 if speed attribute is not modelled
   p = (currentusage / (component.speed or 1e09)) * 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"
   # Change the summary to display input/ouput and correct units
   from Products.ZenUtils.Utils import convToUnits
   evt.summary = "High Interface " + evtNewKey + " Utilization: Currently %3.0f%% used (%s)" % (p, convToUnits(currentusage,1024,'bps'))
   # Update the message to the summary
   evt.message = evt.summary