'evt' is the event.  Here's a bit of a walk-through

#if the index is given from the event, set the index to it
   index = getattr(evt, 'ifIndex', 0)

#it sets the descr to the description of the interface if that's what  
is creating the event.
   descr = getattr(evt, 'ifDescr', 'Unknown Interface')

#then it sets the event component to the interface
   evt.component = descr

#if there is a device associated with the event
   if device:

#we set the description blank
   description = ''

#and check the interfaces on the device
   for iface in device.os.interfaces():

#if the iterated index matches from the event
         if index and iface.ifindex == index:
#we set the description to the interface description
             descr = iface.description
#or else we check if the interface name and descr match
         elif descr and iface.name == descr:
#and get the description off of the interface
             descr = iface.description

#and then we set the event summary
evt.summary = 'Link down on %s' % (descr)


The formatting is all wrong, but hopefully it's a little clearer  
(opaque mud?).

Thanks,
Matt Ray
Zenoss Community Manager
community.zenoss.com
[email protected]




On Apr 7, 2009, at 9:50 AM, kingpin wrote:

> Thanks for the link Matt,
>
> Since I'm a python illeterate I only got this far :
>
> Code:
>
> descr = getattr(evt, 'ifDescr', 'Unknown Interface')
> interface = evt.component
>
> if evt.summary.startswith('threshold of Operational State'):
>    if evt.severity > 0:
>        evt.summary = 'Link down on %s' %(descr)
>    else:
>        evt.summary =  'Link up on %s' %(descr)
>
>
>
> It always returns : "Link down on Unknown Interface", but I'm sure  
> there's a description.
>
> I've looked up 'getattr' and It seems to get an attribure for an  
> object and I've its not there it assigns 'Unknown interface'.
>
> How does it know for which object it should get the discription ?  
> What does evt mean ?
>
>
>
>
> -------------------- m2f --------------------
>
> Read this topic online here:
> http://forums.zenoss.com/viewtopic.php?p=33132#33132
>
> -------------------- m2f --------------------
>
>
>
> _______________________________________________
> zenoss-users mailing list
> [email protected]
> http://lists.zenoss.org/mailman/listinfo/zenoss-users

_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to