Subject: |
RE: Help with getting value for bgpPeerState.ifIndex in transform? |
Author: |
Jane Curry |
Posted: |
2018-02-07 05:16 |
Hi Andy,
Your problem isn't with 6 - it changed in Zenoss 4! There was a major redesign of the whole events subsystem and that trick you are using with "for attr in dir(evt):" stopped working.
Get my "Zenoss 4 Event Management "paper from
https://www.skills-1st.co.uk/papers/jane/zenoss4-events/ and have a look around page 105. There is an example of "old-style" code and "new-style" code. The new way should still work fine with V6.1.
Cheers,
Jane
------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------
Subject: |
RE: Help with getting value for bgpPeerState.ifIndex in transform? |
Author: |
Andy Fleming |
Posted: |
2018-02-07 11:51 |
Thanks Jane
------------------------------
Andy Fleming
KanREN - Kansas Research and Education Network
KS
------------------------------
Subject: |
RE: Help with getting value for bgpPeerState.ifIndex in transform? |
Author: |
Andy Fleming |
Posted: |
2018-02-07 13:10 |
Jane, thanks for the point in the right direction. I seem to still be missing something, or something else has changed. Before at least the transform would save even tho it didn't work. Now when I save it an error for the line the for statement is on "SyntaxError: invalid syntax (<string>, line 52)"
I changed this:
for attr in dir(evt):
if attr.startswith('bgpPeerState.'):
evt.bgpPeerIp = attr.replace('bgpPeerState.', '')
To This:
for attr in evt.details._map.keys():
if attr.startswith('bgpPeerState.'):
evt.bgpPeerIp=attr.replace('bgpPeerState.','')
And other thoughts?
------------------------------
Andy Fleming
KanREN - Kansas Research and Education Network
KS
------------------------------
Subject: |
RE: Help with getting value for bgpPeerState.ifIndex in transform? |
Author: |
Andy Fleming |
Posted: |
2018-02-13 10:43 |
For anyone that finds/reads this thread, here is the code that finally worked.
for attr in evt.details._map.keys():
if attr.startswith('bgpPeerState.ifIndex'):
evt.bgpPeerIp = evt.details.get(attr)
You might just want to type out, because I think some of my problem might have been a non-printable character or something that ended up in there.
------------------------------
Andy Fleming
KanREN - Kansas Research and Education Network
KS
------------------------------