Dec 4, 2011 6:26 AM
match multiple attributes within trap
-
Like (0)
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:
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://"
evt.Classkey="isdndown"
evt.eventClass="/HW/Phones/isdndown/"
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.
Rule:
hasattr(evt, 'OID1') and hasattr(evt, 'OID2')
Transform:
oid1 = getattr(evt, 'OID1', None)
oid2 = getattr(evt, 'OID2', None)
if oid1 and oid2 and device:
do_something
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||