http://qs1969.pair.com?node_id=105966


in reply to Cisco SNMP CDP Poll

I seem to have hit a snag. During a poll I get the following results. Always on the same set of routers.
Illegal hexadecimal digit ' ' ignored at ./cdppoll line 99, <STDIN> line 1. Illegal hexadecimal digit 'X' ignored at ./cdppoll line 100, <STDIN> l +ine 1. Use of uninitialized value in hex at ./cdppoll line 102, <STDIN> line +1. 0.0.0.0 vadgw001.winstar.com Serial2/2 + cisco 7206
Trying to trace it down I added some statements to the Get_SNMP_Info sub Get_SNMP_Info{ #This sub gets the value of an oid
my($crap , $value , $result); my($oid) = $_[0]; $result = $session->get_request("$oid"); $result = $session->get_request("$oid"); #return unless (defined $result); ($crap , $value) = %$result; print "DEBUG: $oid = $value\n"; print "DEBUG: $oid = $crap\n"; return $value; }
and come up with this:
DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.4.7.429 = X> DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.4.7.429 = 1.3.6.1.4.1.9.9.23.1.2.1.1 +.4.7.429 substr outside of string at ./cdppoll line 97, <STDIN> line 1. Illegal hexadecimal digit ' ' ignored at ./cdppoll line 99, <STDIN> line 1. Illegal hexadecimal digit 'X' ignored at ./cdppoll line 100, <STDIN> l +ine 1. Use of uninitialized value in hex at ./cdppoll line 102, <STDIN> line +1. DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.6.7.429 = vadgw001.winstar.com DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.6.7.429 = 1.3.6.1.4.1.9.9.23.1.2.1.1 +.6.7.429 DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.7.7.429 = Serial2/2 DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.7.7.429 = 1.3.6.1.4.1.9.9.23.1.2.1.1 +.7.7.429 DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.8.7.429 = cisco 7206 DEBUG: 1.3.6.1.4.1.9.9.23.1.2.1.1.8.7.429 = 1.3.6.1.4.1.9.9.23.1.2.1.1 +.8.7.429 0.0.0.0 vadgw001.winstar.com Serial2/2 + cisco 7206
I can't figure out where the X> is coming from. I do an snmpget on that same oid and get good results.
snmpget -v2c vaugw001 something .1.3.6.1.4.1.9.9.23.1.2.1.1.4.7.429 enterprises.9.9.23.1.2.1.1.4.7.429 = Hex: 0A 00 58 3E
Has anyone reported this yet? It happens every time on exactly the same entries. Kevin

Replies are listed 'Best First'.
Re^2: Cisco SNMP CDP Poll
by Anonymous Monk on Jun 23, 2006 at 12:20 UTC
    some devices do not insert a 0x infront of hex ip The result is that the ip could not be translated. Maybe this could solve the problem?!
    ################################################## sub Convert_IP { my($ip , $result , $crap); my($hex1 , $hex2 , $hex3 , $hex4); my($oct1 , $oct2 , $oct3 , $oct4); my($hex_ip) = $_[0] ; #========================================================= +================== # Manche Geräte schicken die hexadezimale IP-Adresse # ohne führendes "0X" welches eine Hexadezimale Zahl # kennzeichnet # Für den Fall das keine "0x" mitgeschickt wird unter # Umständen die $hex_ip als ASCII Zeichen intepretiert. # Diese Schleife wandelt das ASCII Zeichen in eine # Hexadezimale Zahl um # und setzt ein "0x" vor den String. Die so neu generierte # Hexadezimale Zahl # kann dann wiederum weiterverarbeitet werden #===================================================================== +====== if (length($hex_ip) ne '10') { my @hexadezimale_IP_Adresse_ohne_0x=unpack("H2" x length($hex_ip), pac +k("A*",$hex_ip)); unshift @hexadezimale_IP_Adresse_ohne_0x, "0x"; $hex_ip = join("", @hexadezimale_IP_Adresse_ohne_0x); $hex_ip =~ s/\s+//g; print qq~hex_ip: $hex_ip\n~; } if (substr($hex_ip,0,1) eq "") { $ip = "0.0.0.0"; print "IP: $ip\n"; } else { $hex_ip =~ s/0x//g; $hex1 = (substr $hex_ip,0,2); $hex2 = (substr $hex_ip,2,2); $hex3 = (substr $hex_ip,4,2); $hex4 = (substr $hex_ip,6,2); $oct1 = hex($hex1); $oct2 = hex($hex2); $oct3 = hex($hex3); $oct4 = hex($hex4); $ip = ("$oct1\.$oct2\.$oct3\.$oct4"); } return $ip; }
      In my case I have found that some devices return strange output, it is in case no mgmt IP is available in sh cdp nei detail (CSS11501), older IOS or different platform.
      DB<69> p $_[0] DB<70> x $_[0] 0 "\c@\c@\c@\c@"
      My dirty hack for that was just check for valid hex-like input
      #if (substr($hex_ip,0,1) eq ""){ if ($hex_ip !~ m/0x.*/){ $ip = "0.0.0.0"; }
        is there a way to modify this script so that it will cycle through a list of choices to use for comminuty string on each device it is polling? Sorry I have no experience at coding, but this script is EXACTLY what I need. I am doing a discovery, I have a list of possible community strings though so i am stuck.