Configuration & Administration

1.  Help with getting value for bgpPeerState.ifIndex in transform?

Posted 20 days ago
All, we currently have a Zenoss 2.5.2 install with a number of transforms and I'm working with 6.1.0 to get it ready to replace our really really old setup.  I've run across what seems to be a difference in how indexed values are handled and how to get a value to use in the transform.

We have a BGP transform similar to the one on this Zenoss WIKI page to get the BGP Peer's IP Address.  Event Transforms and Examples - Zenoss WikiEvent Transforms and Examples - Zenoss Wiki

On our old Zenoss install one of the event details displays as (its decoded more then the WIKI example because we have the MIBs loaded).

bgpPeerState.10.1.1.164   value 1

So our current transform (like the WIKI example) uses:

for attr in dir(evt):
  if attr.startswith('bgpPeerState.'):
    evt.bgpPeerIp = attr.replace('bgpPeerState.', '')


With Zenoss 6 the same code does not seem to work, I think maybe because it handles those indexed values a little differently.  This is what is displayed as the details of the exact same event.

bgpPeerState                  value 1
bgpPeerState.ifIndex      value  10.1.1.164

I'm guessing the change is to make it easier to get that indexed value, in this case 1, but I can't figure out how to get the IP.  I've tried the same code, I've tried evt.bgpPeerIp = bgpPeerState.ifIndex, evt.bgpPeerIp = attr.replace('bgpPeerState.ifIndex',"").  Non of which seem to work.


If I really knew python, I'd guess it's not that hard, but I haven't been able to figure out out yet.  Does anyone have any suggestions or have you already run into this?

Thanks in advance for any guidance.  ---  Andy

------------------------------
Andy Fleming
KanREN - Kansas Research and Education Network
KS
------------------------------


2.  RE: Help with getting value for bgpPeerState.ifIndex in transform?

Posted 18 days ago
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
------------------------------



3.  RE: Help with getting value for bgpPeerState.ifIndex in transform?

Posted 18 days ago
Thanks Jane

------------------------------
Andy Fleming
KanREN - Kansas Research and Education Network
KS
------------------------------



4.  RE: Help with getting value for bgpPeerState.ifIndex in transform?

Posted 18 days ago
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
------------------------------



5.  RE: Help with getting value for bgpPeerState.ifIndex in transform?

Posted 12 days ago
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
------------------------------