Something that is actually a pain in zenoss is testing a transform. There
isn't an easy way in the dmd (that I know of) to recreate the evt object
exactly as it exists at the time of transform.
I have a bit of code you can look at for link up/down if you like.
Code:
#Copper Mountain Customer info
for key,value in evt.__dict__.items():
if key.startswith('1.3.6.1.4.1.1996.20.15.1.1.1'):
evt.summary="%s Customer: %s" % (evt.summary,value)
try:
evt.component = evt.ifDescr
except AttributeError:
try:
index = evt.ifIndex
except AttributeError:
index = None
if index is not None:
evt.component = [x[1].id for x in device.os.interfaces.objectItems() if
x[1].ifindex == index ][0]
This sets the component to the interface name looking first in the trap for the
ifDescr and if it doesn't exist there it looks through the interface list.
The very first part of the transform also grabs the customer name from Copper
Mountain DSLAM interfaces. That is complex because that var-bind has an
arbitrary OID suffix. You have to walk though the whole list of variables in
the trap looking for a prefix.
What exactly are you trying to put into the summary of the device down events?
Nick.
pregan wrote:
> thanks guys .. its made me more confused but thanks ..
>
> the code i'm trying to Frankenstein (from the forum) into what i want is :
>
> index = getattr(evt, 'ifIndex', 0)
> descr = getattr(evt, 'ifDescr', 'Unknown Interface')
>
> evt.component = descr
>
> if device:
> description = ''
> for iface in device.os.interfaces():
> if index and iface.ifindex == index:
> descr = iface.description
> elif descr and iface.name == descr:
> descr = iface.description
>
> evt.summary = 'Link down on %s' % (descr)
>
> it shows the interface description in the error summary for links up and down
> .. i'm trying to do the same thing but for a device down detected by zenping.
>
> i thought i'd find device.os.interfaces in zendmd. i could then mess around
> and try to butcher together what i want .. so it missing has thrown me.
>
> confused ... going on holiday, hopefully the zenoss book will be here when i
> get back ..
>
> thanks for your replies
-------------------- m2f --------------------
Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=24724#24724
-------------------- m2f --------------------
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users