etingof / snmpfwd

SNMP Proxy Forwarder
http://snmplabs.com/snmpfwd/
BSD 2-Clause "Simplified" License
67 stars 18 forks source link

Try to use snmpfwd converting v1 to v2c but it is not working #18

Closed almendes closed 7 years ago

almendes commented 7 years ago

This is the error that I got when I try to use snmpfwd to convert from v1 to v2c ...


2017-08-29 12:14:43,758 ERROR poll error: Traceback (most recent call last): ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher use_poll=True, map=self.sockMap, count=1) ; File "/usr/lib/python2.7/asyncore.py", line 220, in loop poll_fun(timeout, map) ; File "/usr/lib/python2.7/asyncore.py", line 201, in poll2 readwrite(obj, flags) ; File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite obj.handle_error() ; File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite obj.handle_read_event() ; File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event self.handle_read() ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read self._cbFun(self, transportAddress, incomingMessage) ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun self, transportDomain, transportAddress, incomingMessage ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in receiveMessageCbFun self, transportDomain, transportAddress, wholeMsg ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 420, in receiveMessage pdu=PDU) ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/observer.py", line 56, in storeExecutionContext cbFun(snmpEngine, execpoint, variables, self.__contexts[cbFun]) ; File "/usr/local/bin/snmpfwd-server.py", line 418, in requestObserver '|'.join([str(x[0]) for x in apiPDU.getVarBinds(variables['pdu'])])] ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/api/v1.py", line 119, in getVarBinds return [apiVarBind.getOIDVal(varBind) for varBind in pdu.getComponentByPosition(3)] ;TypeError: 'Integer' object is not iterable

Below I copied the configuration file used during this test.

#

SNMP TRAP forwarder: Manager part configuration

#

config-version: 2 program-name: snmpfwd-server

snmp-credentials-group { snmp-transport-domain: 1.3.6.1.6.1.1.100 snmp-bind-address: 127.0.0.1:1234

snmp-engine-id: 0x0102030405070809

snmp-community-name: Ik0n0graf1c0 snmp-security-name: Ik0n0graf1c0

snmp-security-model: 1 snmp-security-level: 1

snmp-credentials-id: snmp-credentials }

context-group { snmp-context-engine-id-pattern: .? snmp-context-name-pattern: .?

snmp-context-id: any-context }

content-group { snmp-pdu-type-pattern: (TRAPv1|TRAPv2) snmp-pdu-oid-prefix-pattern-list: .*?

snmp-content-id: trap-content }

peers-group { snmp-transport-domain: 1.3.6.1.6.1.1.100 snmp-bind-address-pattern-list: .? snmp-peer-address-pattern-list: .?

snmp-peer-id: 100 }

trunking-group { trunk-bind-address: 127.0.0.1 trunk-peer-address: 127.0.0.1:30301 trunk-ping-period: 60 trunk-connection-mode: client

trunk-id: trunk-1 }

routing-map { matching-snmp-credentials-id-list: snmp-credentials matching-snmp-context-id-list: any-context matching-snmp-content-id-list: trap-content matching-snmp-peer-id-list: 100

using-trunk-id-list: trunk-1 }

Could you help me any how ?

etingof commented 7 years ago

Thank you for your report!

It would be helpful if you could re-run the crashing tool with debugging enabled (--debug-snmp=msgproc,secmod,io,dsp) and attach the debugging output to this issue.

almendes commented 7 years ago

this is the output.log ...

2017-08-30 11:24:17,249 handle_read: transportAddress ('127.0.0.1', 34045) -> ('127.0.0.1', 1234) incomingMessage (77 octets) 00000: 30 4B 02 01 00 04 0C 49 6B 30 6E 30 67 72 61 66 00016: 31 63 30 A4 38 06 0C 2B 06 01 04 01 81 9F 38 04 00032: 01 01 02 40 04 7F 00 00 01 02 01 06 02 02 01 B0 00048: 43 02 30 39 30 17 30 15 06 08 2B 06 01 02 01 01 00064: 01 00 04 09 6D 79 20 73 79 73 74 65 6D 2017-08-30 11:24:17,251 receiveMessage: msgVersion 0, msg decoded 2017-08-30 11:24:17,252 prepareDataElements: Message: version='version-1' community=XXXX data=PDUs: trap=TrapPDU: enterprise=1.3.6.1.4.1.20408.4.1.1.2 agent-addr=NetworkAddress: internet=127.0.0.1

generic-trap='enterpriseSpecific' specific-trap=432 time-stamp=12345 variable-bindings=VarBindList: VarBind: name=1.3.6.1.2.1.1.1.0 value=ObjectSyntax: simple=SimpleSyntax: string=my system

2017-08-30 11:24:17,252 _com2sec: built transport-to-tag map version 0: {} 2017-08-30 11:24:17,252 _com2sec: built securityName to securityModel map, version 0: {} 2017-08-30 11:24:17,253 _com2sec: built communityName to tag map (securityModel 1), version 4: {OctetString('XXXX'): set([SnmpTagValue('')])} 2017-08-30 11:24:17,253 _com2sec: built tag & community to securityName map (securityModel 1), version 4: {(SnmpTagValue(''), OctetString('XXXX')): set([(SnmpAdminString('XXXX', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(1, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))), SnmpEngineID(hexValue='0102030405070809'), SnmpAdminString('', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(0, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))))])} 2017-08-30 11:24:17,253 _com2sec: securityName candidates for communityName 'XXXX' are [(SnmpAdminString('XXXX', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(1, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))), SnmpEngineID(hexValue='0102030405070809'), SnmpAdminString('', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(0, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))))]; choosing securityName 'XXXX' 2017-08-30 11:24:17,253 processIncomingMsg: looked up securityName SnmpAdminString('XXXX', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(1, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))) securityModel 1 contextEngineId SnmpEngineID(hexValue='0102030405070809') contextName SnmpAdminString('', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(0, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))) by communityName OctetString('XXXX') AND transportInformation (ObjectName('1.3.6.1.6.1.1.100'), ('127.0.0.1', 34045)) 2017-08-30 11:24:17,253 processIncomingMsg: generated maxSizeResponseScopedPDU 65379 securityStateReference 461294 2017-08-30 11:24:17,253 prepareDataElements: SM returned securityEngineId SnmpEngineID(hexValue='0102030405070809') securityName SnmpAdminString('XXXX', subtypeSpec=ConstraintsIntersection(ValueSizeConstraint(1, 32), ValueSizeConstraint(0, 65535), ValueSizeConstraint(0, 255))) 2017-08-30 11:24:17,253 receiveMessage: MP succeded 2017-08-30 11:24:17,253 receiveMessage: PDU TrapPDU: enterprise=1.3.6.1.4.1.20408.4.1.1.2 agent-addr=NetworkAddress: internet=127.0.0.1

generic-trap='enterpriseSpecific' specific-trap=432 time-stamp=12345 variable-bindings=VarBindList: VarBind: name=1.3.6.1.2.1.1.1.0 value=ObjectSyntax: simple=SimpleSyntax: string=my system

2017-08-30 11:24:17,253 receiveMessage: pduType [128:32:4] 2017-08-30 11:24:17,254 ERROR poll error: Traceback (most recent call last): ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher use_poll=True, map=self.sockMap, count=1) ; File "/usr/lib/python2.7/asyncore.py", line 220, in loop poll_fun(timeout, map) ; File "/usr/lib/python2.7/asyncore.py", line 201, in poll2 readwrite(obj, flags) ; File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite obj.handle_error() ; File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite obj.handle_read_event() ; File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event self.handle_read() ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read self._cbFun(self, transportAddress, incomingMessage) ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun self, transportDomain, transportAddress, incomingMessage ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in receiveMessageCbFun self, transportDomain, transportAddress, wholeMsg ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 420, in receiveMessage pdu=PDU) ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/observer.py", line 56, in storeExecutionContext cbFun(snmpEngine, execpoint, variables, self.__contexts[cbFun]) ; File "/usr/local/bin/snmpfwd-server.py", line 418, in requestObserver '|'.join([str(x[0]) for x in apiPDU.getVarBinds(variables['pdu'])])] ; File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/api/v1.py", line 119, in getVarBinds return [apiVarBind.getOIDVal(varBind) for varBind in pdu.getComponentByPosition(3)] ;TypeError: 'Integer' object is not iterable


To help you, this is the command line that I am using to send the trap ...

sudo snmptrap -v1 -c XXXX 127.0.0.1:1234 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 6 432 12345 1.3.6.1.2.1.1.1.0 s 'my system'

Thanks for your help on that ...

[]'s AL

On Wed, Aug 30, 2017 at 10:47 AM, Ilya Etingof notifications@github.com wrote:

Thank you for your report!

It would be helpful if you could re-run the crashing tool with debugging enabled (--debug-snmp=msgproc,secmod,io,dsp) and attach the debugging output to this issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/etingof/snmpfwd/issues/18#issuecomment-325995573, or mute the thread https://github.com/notifications/unsubscribe-auth/ADGLyURyqE3vnNjJ_yl8kL4geyFfyaCOks5sdWgPgaJpZM4PHYs_ .

etingof commented 7 years ago

I believe this issue has been fixed in current master. I'd appreciate you testing it. Thanks!

almendes commented 7 years ago

Right, so I have to clone github last version? Thanks in advance. []`s AL

On Aug 30, 2017 18:43, "Ilya Etingof" notifications@github.com wrote:

I believe this issue has been fixed at current master.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/etingof/snmpfwd/issues/18#issuecomment-326127906, or mute the thread https://github.com/notifications/unsubscribe-auth/ADGLyVVPG-abb-zJ8X943LmkQaCVkR4Dks5sddeNgaJpZM4PHYs_ .

etingof commented 7 years ago

You can pip install right from GitHub repo. Or download .zip and install it locally. Or clone (or fork->clone) the repo and install from there.

almendes commented 7 years ago

Ok thanks ... its works flawless ... very good work.

[]'s AL

On Wed, Aug 30, 2017 at 9:11 PM, Ilya Etingof notifications@github.com wrote:

You can pip install https://stackoverflow.com/questions/15268953/how-to-install-python-package-from-github right from GitHub repo. Or download .zip and install it locally. Or clone (or fork->clone) the repo and install from there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/etingof/snmpfwd/issues/18#issuecomment-326153077, or mute the thread https://github.com/notifications/unsubscribe-auth/ADGLyW8pjP-9Th7Gewuq83aSV5UVYbvWks5sdfolgaJpZM4PHYs_ .