glenpcarter
2013-10-07 15:07:04 UTC
glenpcarter [http://community.zenoss.org/people/glenpcarter] created the discussion
"Problem with getting Interface Number from Trap after upgrade to 4.2.3"
To view the discussion, visit: http://community.zenoss.org/message/74861#74861
--------------------------------------------------------------
Hi All
I am having some issues getting my SNMP Traps to give me the Interface number of the switch that is alerting. In Core3 we had this working beautifully using a simple Transform which I have included below.
 0 index = getattr(evt, 'ifIndex', 0)
 1 descr = getattr(evt ,'ifDescr', index)
 2 if descr != index:
 3    evt.component = descr
 4 else:
 5    if device == None:
 6        evt.component = index
 7    else:
 8        found = 0
 9        for obj in device.os.interfaces.objectItems():
10Â Â Â Â Â Â Â Â Â Â Â Â if obj[1].ifindex == index:
11Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â evt.component = obj[1].id
12Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â found = 1
13Â Â Â Â Â Â Â Â if found == 0:
14Â Â Â Â Â Â Â Â Â Â Â Â evt.component = index
15 if evt.component.startswith('Gigabit'):
16Â Â Â Â evt.severity = 3
17 if evt.component.startswith('Ethernet'):
18Â Â Â Â Â Â Â Â evt.severity = 3
19 if evt.component.startswith('Cascade'):
20Â Â Â Â Â Â Â Â evt.severity = 4
Now since the upgrade to Core 4 this transform has stopped working and now all I et is the ifIndex value instead of the actual port number. What I do get is the following errors
2013-08-09 15:48:11,864 INFO zen.Events: Transform error <type 'int'> has type <type 'int'>, but expected one of: str, unicode; aborting transaction
2013-08-09 15:48:11,933 WARNING zen.Events: Error processing transform/mapping on Event Class /Net/Link/instances/snmp_linkDown
Problem on line 82: TypeError: <type 'int'> has type <type 'int'>, but expected one of: str, unicode
I'm not really a Python expert and was hoping that someone maybe able to shed some light on this to help me work out where this transform is failing.
Thanks
Glen
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74861#74861]
Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
"Problem with getting Interface Number from Trap after upgrade to 4.2.3"
To view the discussion, visit: http://community.zenoss.org/message/74861#74861
--------------------------------------------------------------
Hi All
I am having some issues getting my SNMP Traps to give me the Interface number of the switch that is alerting. In Core3 we had this working beautifully using a simple Transform which I have included below.
 0 index = getattr(evt, 'ifIndex', 0)
 1 descr = getattr(evt ,'ifDescr', index)
 2 if descr != index:
 3    evt.component = descr
 4 else:
 5    if device == None:
 6        evt.component = index
 7    else:
 8        found = 0
 9        for obj in device.os.interfaces.objectItems():
10Â Â Â Â Â Â Â Â Â Â Â Â if obj[1].ifindex == index:
11Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â evt.component = obj[1].id
12Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â found = 1
13Â Â Â Â Â Â Â Â if found == 0:
14Â Â Â Â Â Â Â Â Â Â Â Â evt.component = index
15 if evt.component.startswith('Gigabit'):
16Â Â Â Â evt.severity = 3
17 if evt.component.startswith('Ethernet'):
18Â Â Â Â Â Â Â Â evt.severity = 3
19 if evt.component.startswith('Cascade'):
20Â Â Â Â Â Â Â Â evt.severity = 4
Now since the upgrade to Core 4 this transform has stopped working and now all I et is the ifIndex value instead of the actual port number. What I do get is the following errors
2013-08-09 15:48:11,864 INFO zen.Events: Transform error <type 'int'> has type <type 'int'>, but expected one of: str, unicode; aborting transaction
2013-08-09 15:48:11,933 WARNING zen.Events: Error processing transform/mapping on Event Class /Net/Link/instances/snmp_linkDown
Problem on line 82: TypeError: <type 'int'> has type <type 'int'>, but expected one of: str, unicode
I'm not really a Python expert and was hoping that someone maybe able to shed some light on this to help me work out where this transform is failing.
Thanks
Glen
--------------------------------------------------------------
Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/74861#74861]
Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]