CDP discovery fails to find cisco nexus neighbors

:wave:Hello LibreNMS developers :+1:t2:,

TLDR; fails to discover cisco nexus which CDP advertises as sysName(SerialNumber) instead of sysName

Long version :
some cisco nexus switches send a formated string like FQDN(SerialNumber) as the snmp cdpCacheDeviceId value and you can’t tweak that through cisco IOS. LibreNMS retrieves the CDP information thanks to which does :
$cdp_array = snmpwalk_cache_twopart_oid($device, 'cdpCache', array(), 'CISCO-CDP-MIB');
This retrieves deviceID formatted as sysName(SerialNumber) in the case of nexus devices :frowning:
Then $cdp is built but the SerialNumber in parenthesis is not removed and it causes the nexus device not to be identified as a neighbor.

To fix that, I suggest to check the format of cdpCacheDeviceId and remove the (SerialNumber) part from it thanks to a simple preg_replace call.

Would anyone please do it ?
I do have over 300 switches to monitor and tens of these are nexus switches. I thus have a hole in my map.

Thanks in advance and thank you for LibreNMS !

1 Like

Sounds like you pretty much have it figured out. It would be great if you could make the fix and submit it for others.