cdpwalker icon indicating copy to clipboard operation
cdpwalker copied to clipboard

Error when performing Scan

Open jbilder opened this issue 9 years ago • 2 comments

Thanks for creating this script. I see a lot of uses where this will be extremely helpful finding devices. I'm working on modifying the script to add an array of snmp community strings that can be imported via a text file. Outside of making any changes, I'm running into a problem with the following:

./cdpwalker.py test.txt 10.11.30.254 2016-08-17 19:13:07,516 - cdpwalker - INFO - processing host: 10.11.30.254 Traceback (most recent call last): File "./cdpwalker.py", line 205, in h, rel = get_cdp_neighbors(host) File "./cdpwalker.py", line 148, in get_cdp_neighbors (struct.unpack("BBBB", value)) struct.error: unpack requires a string argument of length 4

Any insight is much appreciated. Thanks!

jbilder avatar Aug 18 '16 00:08 jbilder

I'm also getting this error:

./cdpwalker.py test.txt 10.9.2.1 2016-08-17 19:09:42,536 - cdpwalker - INFO - processing host: 10.9.2.1 2016-08-17 19:09:43,423 - cdpwalker - INFO - host 10.9.2.1 done 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,423 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - new host to query 2016-08-17 19:09:43,424 - cdpwalker - INFO - processing host: Traceback (most recent call last): File "./cdpwalker.py", line 205, in h, rel = get_cdp_neighbors(host) File "./cdpwalker.py", line 134, in get_cdp_neighbors r = snmp.snmp_getnext(OID_CDP_CACHE_ENTRY) File "./cdpwalker.py", line 94, in snmp_getnext snmp_config, cmdgen.UdpTransportTarget((self.host, self.port)), oid) File "/usr/local/lib/python2.7/dist-packages/pysnmp/hlapi/transport.py", line 17, in init self.transportAddr = self._resolveAddr(transportAddr) File "/usr/local/lib/python2.7/dist-packages/pysnmp/hlapi/asyncore/transport.py", line 58, in _resolveAddr raise error.PySnmpError('Bad IPv4/UDP transport address %s: %s' % ('@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) pysnmp.error.PySnmpError: Bad IPv4/UDP transport address @161: [Errno -3] Temporary failure in name resolution

jbilder avatar Aug 18 '16 00:08 jbilder

It seems like one of the devices returned data from its CDP table the script can't handle. To investigate this issue further, you would have to add a "print (host)" statement before the call to get_cdp_neighbors. This should help to identify the device which made the script fail.

I haven't used the tool in years myself :-) It definitely needs a complete rewrite someday. But I'm not sure when this is going to happen :D

verbosemode avatar Aug 22 '16 22:08 verbosemode