Discussion:
Event Attribute Help
istoptofly
2012-05-08 15:58:11 UTC
Permalink
istoptofly [http://community.zenoss.org/people/istoptofly] created the discussion

"Event Attribute Help"

To view the discussion, visit: http://community.zenoss.org/message/66265#66265

--------------------------------------------------------------
I'm having some trouble pulling info out of the event for my transform and need some help. 

This is my transform -

import re

ontName = getattr(evt,'enterprises.4323.2.2.1.3.14.1.11.[0-9]+','')
evt.summary = "ONT " + ontName + " battery low, check AXSVision client for more info on this alert."

And this is the info I'm trying to get from Event Details -

enterprises.4323.2.2.1.3.14.1.11.11656   AU-1-4-1-ONT

The issue is my transform is not getting AU-1-4-1-ONT from the event.  I'm using a regex in the transform as the last 5 digits of the event can vary.

Anyone see why this isn't working?

Thanks,

John
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/66265#66265]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jcurry
2012-05-08 17:01:24 UTC
Permalink
jcurry [http://community.zenoss.org/people/jcurry] created the discussion

"Re: Event Attribute Help"

To view the discussion, visit: http://community.zenoss.org/message/66282#66282

--------------------------------------------------------------
I think your problem is that the second parameter to getattr has to be a string and cannot be a regular expression like you have provided (,'enterprises.4323.2.2.1.3.14.1.11.[0-9]+'   ).  Thus, since you have provided the null string as the default, that is what you always get.

The way I have solved this sort of thing in transforms for OID stuff is like:

for attr in dir(evt):
    if attr.startswith('1.3.6.1.4.1.123.'):
    evt.myRestOfOID=attr.replace('1.3.6.1.4.1.123.','')
    evt.myFieldValue=getattr(evt,attr)
          evt.summary=(evt.summary+" "+evt.myFieldValue+"  ")
           . . . . ..

Cheers,
Jane
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/66282#66282]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...