TECHZEN Zenoss User Community ARCHIVE  

Transform modification help needed perf / interface

Subject: Transform modification help needed perf / interface
Author: Dannon
Posted: 2015-04-22 10:44

Hello. I am using the following transform on my perf/interface class on Zenoss 4.2.5:
--------------------------------------------
#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
----------------------------

My problem is that I am getting errors when the transforms runs against a loopback address of 127.0.0.1
------------------------------
Resource: localhost
Component: /Perf/Interface
Event Class: /
Status: New
Message: Problem with line 11: p = (currentusage / f.speed) * 100
....
DeviceClass /Server/Linux
DeviceGroups
DevicePriority Normal
Location /HOCHS
Systems
device localhost
ipAddress 127.0.0.1
monitor
prodState Production

I'm not sure how to modify my transform to ignore the 127.0.0.1 so I don't get the errors.

Any smart coding people out there who could help me out I'm just a lowly Cisco guy. :)

Dannon



Subject: change line 11 to p =
Author: ValeruS
Posted: 2015-04-23 02:56

change line 11 to p = (currentusage / (f.speed or 1)) * 100




Subject: That fixed it. Thanks!
Author: Dannon
Posted: 2015-04-29 14:07

That fixed it.

Thanks!



< Previous
Zenoss 5 - disable HTTPS
  Next
OS Process monitoring over SSH
>