Discussion:
match multiple attributes within trap
gcollis1
2011-12-04 11:26:40 UTC
Permalink
gcollis1 [http://community.zenoss.org/people/gcollis1] created the discussion

"match multiple attributes within trap"

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

--------------------------------------------------------------
Hi,

How can I match multiple attributes within a trap? I have a trap that gets generated and I want to transform this trap only if text within two different oids is matched:

I can get this working on one match, but not two:

e.g. somthing like

import re

match = getattr(evt, "--OID1 from event Details--") and match = getattr(evt, "--OID2 from event Details--")
if match and device:


--------------------------------------------------------------

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

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]
gcollis1
2011-12-05 13:20:58 UTC
Permalink
gcollis1 [http://community.zenoss.org/people/gcollis1] created the discussion

"Re: match multiple attributes within trap"

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

--------------------------------------------------------------
Anyone ?

More specifically here is what i currently have that does not work:

import re

match = re.search('^02', getattr(evt, "enterprises.6889.2.8.1.4.6.1.1"))
if match and device:
        evt.component="isdn phone line"
match = re.search('^ISDN-TRK', getattr(evt, "enterprises.6889.2.8.1.4.6.1.3"))
if match and device:
        evt.summary = "DR ISDN trunk(s) down! " + " " + getattr(evt, "enterprises.6889.2.8.1.4.6.1.3") + "  " + getattr(evt, "enterprises.6889.2.8.1.4.6.1.1") + " " + "Please see http:// http://"
evt.Classkey="isdndown"
evt.eventClass="/HW/Phones/isdndown/"
--------------------------------------------------------------

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

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]
Chet Luther
2011-12-07 15:19:44 UTC
Permalink
Chet Luther [http://community.zenoss.org/people/cluther] created the discussion

"Re: match multiple attributes within trap"

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

--------------------------------------------------------------
You can do it either in the mapping's +rule+ field, or in the +transform+ field like you appear to be doing. The rule field would be the place to do it if you didn't even want you mapping to match the event unless the two varbinds existed. The transform field happens after the mapping has matched an event.
hasattr(evt, 'OID1') and hasattr(evt, 'OID2')
oid1 = getattr(evt, 'OID1', None)
oid2 = getattr(evt, 'OID2', None)
    do_something
--------------------------------------------------------------

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

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...