Sep 27, 2011 4:28 AM
Problem Installing Shane Scotts Device Search
-
Like (0)
Hello everybody,
i am using Zenoss Core Version 3.2.0 and want to have a global search function for the interface descriptions. In the IRC Channel hackman238(i think he was Shane Scott) told me that his ZenPack Device Search does this job after a little modifcation.
I have to add "device.os.interfaces.interface.description" in line 30 in "%ZENHOME/ZenPacks/ZenPacks.ShaneScott.DeviceSearch-1.0.0-py2.6.egg/ZenPacks/ShaneScott/DeviceSearch/__init__.py"
But when i install the ZenPack as Zenoss User with the following command: "zenpack --install=ZenPacks.ShaneScott.DeviceSearch-1.0.0-py2.6.egg"
i get a huge Error and Warning list. I suppose it has something to do with some Transforms i had already in Zenoss...
I append a huge log from my console that you can see what i have done till now. (You can jump over the mid part because its a repeating error output)
So can you please take a look over this log and tell me what i have done wrong? At the moment there is still a search box in the top left to the user name, but it doesnt work.
Thanks
Michael
Tito:
No one should ever take your advice for anything after reading your posts.
My packs are not dangerous, infact, this problem is a transform issue which I've been discussing with Mike in IRC.
Best,
--Shane
Yes were talking over IRC to find out why the zenpack isnt working.
The installation of the zenpack has no influences of the stability of the other Zenoss-Stuff.. I can remove or install it. There are only the error messages from the install. All other Zenoss-Related Stuff is working.
Is there a requirement for the normal Global Device Search ZenPack?
For everyone i post here my transforms which i pasted under Events -> event classes -> gear (bottom left) -> Transform:
<code>
import re
# 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
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"
# code to show correct units in events
# 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 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
# 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"
</code>
Now i will post the main error message which is responsible for the disfunction(i think):
After "zenpack --install=ZenPacks.ShaneScott.DeviceSearch-1.0.0-py2.6.egg":
2011-09-26 17:38:24,424 INFO zen.HookReportLoader: loading reports from:/var/zenoss/zenoss/ZenPacks/ZenPacks.ShaneScott.DeviceSearch-1.0.0-py2.6.egg/ZenPacks/ShaneScott/DeviceSearch/reports
2011-09-26 17:38:25,132 WARNING zen.Events: Error processing transform/mapping on Event Class /
Problem on line 2: AttributeError: 'NoneType' object has no attribute 'prepId'
fs_id = device.prepId(evt.component)
btw: how can i make code fields in my post?
Michael:
Try:
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
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"
# code to show correct units in events
# 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 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
# 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"
I think this will work by bailing when device is not set.
--Shane
Today i recognized that my transforms for oppressing the "High-Threshold-Warnings" are not working. Do you know why?
Tito:
Transforms cannot break ZODB or an install. If you ahd problems its because you did not remove the pack, upgrade to zenoss 3 and nistall the new pack. That is how it should be done.
Mike:
Can you post one of the events? I'll double check the code.
I don't know precisely what you want... I post you a screenshot from my Event Console and also the responsible code:
# 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"
in the event console there is an event "Error processing transform/mapping on Event Class" in the detailed view of this event it says:
Problem with line 68: evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Kbps) or %3.2f%% is being used." % (Usage, p)
exception | NameError: name 'evtNewKey' is not defined |
can we talk today on irc?
Also i got an error in the ZenPacks-Overview: It says "This pack was just installed, or is missing or broken. Please restart Zope."
Restarting Zope has no effect.
Another Error is when i want to add a new Datasource under "Monitoring Templates" i get a "Server Exception":
The Server reported the following error:
AttributeError
getDataSourceClasses
The System has encountered an error. Please reload the page.
Reloading doesnt have an effect..
This error is really bad because i cant add any new datasources for new devices!!!
PLEASE HELP!!
Okay restarting the complete Zenoss-Stack solved the last 2 Problems...
isn't there anyone who can help? My Problem from post 9 still exists...
@Shane Scott: did you had time to write the lines for search in interfaces?
maybe this thread can help?: message/57014#57014
Michael s:
I hope you're well! I've recently updated the pack to provide the needed functionality out of the box.
You can find it and documentation here: http://shanewilliamscott.com/Code/devicepropertysearch-zenpack.html
Is your transform still give you grief?
Best,
--Shane W. Scott(Hackman238)
ZCA - community/zca/blog
Hello Shane,
the installation of your new modified Zenpack doesn't work. Even with your new version without version check(i just re-downloaded the *.egg file from your website...)
Here is the output in my console:
zenoss@x:~$ zenpack --install=ZenPacks.ShaneScott.DeviceSearch-1.2.0-py2.6.egg
Not found: zenoss >= 3.2
2011-11-14 11:50:55,764 INFO zen.HookReportLoader: loading reports from:/usr/local/zenoss/zenoss/ZenPacks/ZenPacks.ShaneScott.DeviceSearch-1.2.0-py2.6.egg/ZenPacks/ShaneScott/DeviceSearch/reports
But i am using Zenoss Version 3.2.1. What value is the installer checking for version check?
My current transform is exactly the one you've posted above:
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
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"
# code to show correct units in events
# 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 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
# 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"
These transforms generate a warning in my event list:
Error processing transform/mapping on Event Class /
"Problem with line 72: evt.summary = "High " + evtNewKey + " Utilization: Currently (%3.2f Kbps) or %3.2f%% is being used." % (Usage, p)"
Also Tunnel-, Dialer and Virtual-Access interfaces are generating "threshold of high utilization exeeded: current value xxxxx"-warnings. That means the Transform code you gave me works to install your ZenPack but does not drop the high threshold-warnings. Is there a way to get both things to work?
Greetz
Michael
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"
Michael:
The DeviceSearch pack has been updated to fix the dependancy bug.
Best,
--Shane
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||