TECHZEN Zenoss User Community ARCHIVE  

Help with event transform

Subject: Help with event transform
Author: anon anon
Posted: 2018-09-13 20:16

Hello,

I am trying to write an event transform for the following situation:

I have an SNMP trap that comes in, and when looking in the details, I see the following fields


I would like to write an event transform that looks like the following

if str (getattr(evt, "clogHistFacility.xxx"))=='LINK':
 evt.summary = "Interface state change-" + str (getattr(evt, "clogHistMsgText.xxx"))

My problem is that the number at the end of the "clogHistFacility" and "clogHistMsgText" fields varies, so I need to be able to match a wildcard for the above transform like "clogHistFacility.*" and "clogHistMsgText.*". Each time the trap occurs, the number increments by one.

This is for trying to alert on an SNMP trap for a link up/down on a Cisco switch

How do I indicate/match the last xxx numeric part of the field in a transform? I don't know if I need to use regex somehow, or if there is a much easier way. 

Thanks for the help!

------------------------------
anon anon
anon
TX
------------------------------


Subject: RE: Help with event transform
Author: anon anon
Posted: 2018-09-14 13:52

Hey, I got this working via the below transform

for detail in evt.details._map.keys():
  if detail.startswith('clogHistFacility'):
HistFacility = getattr(evt, detail)
  if detail.startswith('clogHistMsgText'):
HistMsgText = getattr(evt, detail)

if HistFacility=="LINK":
  evt.summary = "Interface state change-" + HistMsgText

------------------------------
anon anon
anon
TX
------------------------------


Subject: RE: Help with event transform
Author: Jane Curry
Posted: 2018-09-14 14:26

Excellent! Sorry - saw your append this morning and then it got manic :(

You might pull the Event Management paper that I wrote if you are looking for more examples in the future - https://www.skills-1st.co.uk/papers/jane/zenoss4-events/  .

Cheers,
Jane

------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------


< Previous
Zenoss 6.1.1 graphs show no data, zenhub and MetricShipper failing some health c ...
  Next
Graphs not working on Zenoss 6
>