Here's what I got for an Interface Transform, seems to work for me.
Code:
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.groups()[0])) * 8
p = (currentusage / f.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"
# Check the speed to determine the appropriate conversion
# 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
Kbps) 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
-------------------- m2f --------------------
Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=28977#28977
-------------------- m2f --------------------
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users