Shane Scott [http://community.zenoss.org/people/hackman238] created the discussion
"Re: Problem Installing Shane Scotts Device Search"
To view the discussion, visit: http://community.zenoss.org/message/62625#62625
--------------------------------------------------------------
Michael:
I think f.speed is sometimes invalid and causing a problem.
Try this:
import re
# test device object is not None
if device:
  # code for showing the 95th percentile in graphs
  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.groups()[0])) * 8
     #computer percent using f.speed where f.speed != None, otherwise assume speed = 1
     speed = (f.speed or 1)
     p = (currentusage / int(speed)) * 100
     evtKey = evt.eventKey
     # Whether Input or Output Traffic
     if evtKey == "ifInOctets_ifInOctets|high utilization":
         evtNewKey = "Input"
     elif evtKey == "ifOutOctets_ifOutOctets|high utilization":
         evtNewKey = "Output"
  # code to show correct units in events
     # Check the speed to determine the appropriate conversion
     # check if speed > 1
     if speed > 1:
         # Gbps utilization
         if currentusage > 1000000000:
             Usage = currentusage / 1000000000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Gbps) or %3.2f%% is being used." % (Usage, p)
         # Mbps utilization
         elif currentusage > 1000000:
             Usage = currentusage / 1000000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Mbps) or %3.2f%% is being used." % (Usage, p)
         # Kbps utilization
         elif currentusage > 1000:
             Usage = currentusage / 1000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Kbps) or %3.2f%% is being used." % (Usage, p)
         # bps utilization
         elif currentusage < 1000:
             Usage = currentusage
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f bps) or %3.2f%% is being used." % (Usage, p)
         break
       else:
         # Gbps utilization
         if currentusage > 1000000000:
             Usage = currentusage / 1000000000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Gbps is being used. Interface speed invalid" % (Usage)
         # Mbps utilization
         elif currentusage > 1000000:
             Usage = currentusage / 1000000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Mbps) is being used. Interface speed invalid" % (Usage)
         # Kbps utilization
         elif currentusage > 1000:
             Usage = currentusage / 1000
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Kbps) is being used. Interface speed invalid" % (Usage)
         # bps utilization
         elif currentusage < 1000:
             Usage = currentusage
             evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f bps) is being used. Interface speed invalid" % (Usage)
         break
  # no generating of "High-Threshold"-Warnings for Tunnel-, Dialer- or Virtual-Access-Interfaces
  if evt.component.find("Tunnel") >= 0:
     evt._action = "drop"
  if evt.component.find("Dialer") >= 0:
     evt._action = "drop"
  if evt.component.find("Virtual-Access") >= 0:
     evt._action = "drop"
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/62625#62625]
Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]