Jonathan - I have been enjoying the features of NetDB a couple years now. I really appreciate the effort you've put into keeping this project active. I recently became aware that devices with an underscore in the hostname are getting truncated in the neighbor table. I am aware that underscore characters are not a good idea because of DNS limitations... however an outside vendor deployed hundreds of wireless access points in my environment and used this character in the hostnames. Here is an example cdp neighbor lookup in a Cisco CLI:
s1-sfmh-68-09-2#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
s1-sfmh-core
Gig 0/51 134 R S I WS-C6513 Gig 9/19
AP2-68_09_2-MAIN-SFMH
Gig 0/13 166 T AIR-CAP350Gig 0
AP8-68_09_2-MAIN-SFMH
Gig 0/29 144 T AIR-CAP350Gig 0
AP3-68_09_2-MAIN-SFMH
Gig 0/14 166 T AIR-CAP350Gig 0
AP9-68_09_2-MAIN-SFMH
Gig 0/30 148 T AIR-CAP350Gig 0
AP1-68_09_2-MAIN-SFMH
Gig 0/12 130 T AIR-CAP350Gig 0
AP6-68_09_2-MAIN-SFMH
Gig 0/26 149 T AIR-CAP350Gig 0
AP7-68_09_2-MAIN-SFMH
Gig 0/28 133 T AIR-CAP350Gig 0
AP4-68_09_2-MAIN-SFMH
Gig 0/15 129 T AIR-CAP350Gig 0
AP5-68_09_2-MAIN-SFMH
Gig 0/16 147 T AIR-CAP350Gig 0
s2-sfmh-68-09-2 Gig 0/52 149 S I WS-C3560G-Gig 0/51
WIP1-68_09_2-MAIN-SFMH
Gig 0/31 139 T AIR-CAP350Gig 0
WIP2-68_09_2-MAIN-SFMH
Gig 0/32 173 T AIR-CAP350Gig 0
However when performing a switch report I see the following adjancies:
Jonathan - in reviewing your source code I think the issue may be in the following line, found in the iosscraper's getCDP subroutine:
// Save remote device name
if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-]+)/ ) {
I am not a regular expression expert, but it appears you are only expecting to capture alphanumeric, '.', and '-'
Would there be a reason we couldn't modify this line to include '_' ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry I haven’t gotten back to you, I’ve been out of the office. That would probably be a quick fix and I can add it to the code if it works for you no problem. I would have gotten to this sooner but I’ve been taking a break from work, thanks again.
Jonathan - in reviewing your source code I think the issue may be in the following line, found in the iosscraper's getCDP subroutine:
// Save remote device name
if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-]+)/ ) {
I am not a regular expression expert, but it appears you are only expecting to capture alphanumeric, '.', and '-'
Would there be a reason we couldn't modify this line to include '_' ?
That looks right to me, did it work for you? I didn’t actually write that code, another contributor did, but that looks right to me. None of our hostnames have underscores, so just let me know if it works and I’ll make the modifications on my end.
Jonathan - it does not appear to have worked. I made the modification last week and the truncated hostnames still show up when I do a switch report. Am I correct in assuming that the updated functionality should have overwritten the original n_hostnames in the neighbor table?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Jonathan - this looks exactly like what I have implemented and I still am seeing truncated neighbor hostnames. Do you have time to validate whether the solution works for you? --Ryan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry I’ve been swamped at work, but I will setup a test early next week and get this resolved. Should be a quick fix, I just need to set it up and test myself.
Jonathan - this looks exactly like what I have implemented and I still am seeing truncated neighbor hostnames. Do you have time to validate whether the solution works for you? --Ryan
I have tested on my end and both underscores and dashes no longer get truncated in both CDP and LLDP data. Please try these files and and let me know if you have an issue. I think you also need to update the NetdbHelper.pm as well since there's been some changes. Please save all local copies of these files before updating them, as one other person had an issue with the library I'm unable to reproduce at this time.
Let me know if that works for you or if you run in to issues updating the library. If so, revert, send me the errors and I can try to work it out. These are development versions for now but I will push the changes in to the next version of v1.13 once we know it's stable.
Jonathan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Jonathan - I have been enjoying the features of NetDB a couple years now. I really appreciate the effort you've put into keeping this project active. I recently became aware that devices with an underscore in the hostname are getting truncated in the neighbor table. I am aware that underscore characters are not a good idea because of DNS limitations... however an outside vendor deployed hundreds of wireless access points in my environment and used this character in the hostnames. Here is an example cdp neighbor lookup in a Cisco CLI:
s1-sfmh-68-09-2#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
s1-sfmh-core
Gig 0/51 134 R S I WS-C6513 Gig 9/19
AP2-68_09_2-MAIN-SFMH
Gig 0/13 166 T AIR-CAP350Gig 0
AP8-68_09_2-MAIN-SFMH
Gig 0/29 144 T AIR-CAP350Gig 0
AP3-68_09_2-MAIN-SFMH
Gig 0/14 166 T AIR-CAP350Gig 0
AP9-68_09_2-MAIN-SFMH
Gig 0/30 148 T AIR-CAP350Gig 0
AP1-68_09_2-MAIN-SFMH
Gig 0/12 130 T AIR-CAP350Gig 0
AP6-68_09_2-MAIN-SFMH
Gig 0/26 149 T AIR-CAP350Gig 0
AP7-68_09_2-MAIN-SFMH
Gig 0/28 133 T AIR-CAP350Gig 0
AP4-68_09_2-MAIN-SFMH
Gig 0/15 129 T AIR-CAP350Gig 0
AP5-68_09_2-MAIN-SFMH
Gig 0/16 147 T AIR-CAP350Gig 0
s2-sfmh-68-09-2 Gig 0/52 149 S I WS-C3560G-Gig 0/51
WIP1-68_09_2-MAIN-SFMH
Gig 0/31 139 T AIR-CAP350Gig 0
WIP2-68_09_2-MAIN-SFMH
Gig 0/32 173 T AIR-CAP350Gig 0
However when performing a switch report I see the following adjancies:
AP1-68
AP2-68
AP3-68
AP4-68
AP5-68
AP6-68
AP7-68
AP8-68
AP9-68
s1-sfmh-core
s2-sfmh-68-09-2
WIP1-68
WIP2-68
Is there a workaround so I can see the full hostname when a '_' character is used? Thanks --Ryan
Jonathan - in reviewing your source code I think the issue may be in the following line, found in the iosscraper's getCDP subroutine:
// Save remote device name
if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-]+)/ ) {
I am not a regular expression expert, but it appears you are only expecting to capture alphanumeric, '.', and '-'
Would there be a reason we couldn't modify this line to include '_' ?
Ryan,
Sorry I haven’t gotten back to you, I’ve been out of the office. That would probably be a quick fix and I can add it to the code if it works for you no problem. I would have gotten to this sooner but I’ve been taking a break from work, thanks again.
Jonathan
Jonathan - is this all that is required?
if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-_]+)/ ) {
Ryan,
That looks right to me, did it work for you? I didn’t actually write that code, another contributor did, but that looks right to me. None of our hostnames have underscores, so just let me know if it works and I’ll make the modifications on my end.
Thanks
Jonathan - it does not appear to have worked. I made the modification last week and the truncated hostnames still show up when I do a switch report. Am I correct in assuming that the updated functionality should have overwritten the original n_hostnames in the neighbor table?
Ryan,
Give this a shot. If it doesn't work, I'll try to create an underscore switch name and test on my end:
if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-_]+)/ ) {
Jonathan
Jonathan - this looks exactly like what I have implemented and I still am seeing truncated neighbor hostnames. Do you have time to validate whether the solution works for you? --Ryan
Ryan,
Sorry I’ve been swamped at work, but I will setup a test early next week and get this resolved. Should be a quick fix, I just need to set it up and test myself.
Jonathan
Ryan,
I have tested on my end and both underscores and dashes no longer get truncated in both CDP and LLDP data. Please try these files and and let me know if you have an issue. I think you also need to update the NetdbHelper.pm as well since there's been some changes. Please save all local copies of these files before updating them, as one other person had an issue with the library I'm unable to reproduce at this time.
NXOS:
https://sourceforge.net/p/netdbtracking/code/HEAD/tree/trunk/netdbscraper/nxosscraper.pl
IOS:
https://sourceforge.net/p/netdbtracking/code/HEAD/tree/trunk/netdbscraper/iosscraper.pl
Library in /opt/netdb/:
https://sourceforge.net/p/netdbtracking/code/HEAD/tree/trunk/NetDBHelper.pm
Let me know if that works for you or if you run in to issues updating the library. If so, revert, send me the errors and I can try to work it out. These are development versions for now but I will push the changes in to the next version of v1.13 once we know it's stable.
Jonathan
Excellent! I will install the files and let you know! --Ryan
Its working great! Thank you very much Jonathan! --Ryan
Great Ryan, sorry it took so long.
Jonathan