For When You Can't Have The Real Thing
[ start | index | login ]
start > MrRogers


Created by dave. Last edited by dave, 9 years and 77 days ago. Viewed 4,279 times. #11
[diff] [history] [edit] [rdf]

MrRogers knows who is in your neighbourhood.

mrrogers is a perl script which uses snmp to query a switch to list its LLDP neighbours. Originally I wanted a perl script that would list the LLDP neighbour on a specific port so that I could run it in a Nagios test and have it bark if an important link was no longer there.

Script is at >>; previous version is at >>

The script requires the CPAN module Net::SNMP


[dave@store01 ~]$ mrrogers --HELP [-c STRING ] [-p] TARGET
    TARGET         query the switch at ip, or named, TARGET
    -c STRING      use STRING as the SNMP community
    -l PORT        show neighbour on PORT only
    -p             display remote PortID strings as well as PortDesc strings
    -s             show local PortID
    --HELP         print this screen

The snmp community defaults to public.


[dave@store01 ~]$ mrrogers sa4-39
ge-0/0/0.0 -> sa4-42 27
ge-0/0/1.0 -> sa4-38 ge-1/0/5.0
ge-0/0/2.0 -> sa4-01 g4
ge-0/0/5.0 -> sa4-16 g24
ge-0/0/9.0 -> sa3-37 ge-1/0/43.0
ge-0/0/15.0 -> sa4-20 g24
ge-0/0/20.0 -> sa4-38 vme.0
ge-0/0/23.0 -> sa4-39 me0.0
ge-0/0/24.0 -> sa7-41 ge-0/0/47.0
ge-0/0/25.0 -> sa7-41 me0.0
ge-0/0/30.0 -> sa5-41 ge-0/0/47.0
ge-0/0/31.0 -> sa5-41 me0.0
ge-0/0/32.0 -> sa6-41 ge-0/0/47.0
ge-0/0/33.0 -> sa6-41 me0.0
ge-0/0/36.0 -> sa3-41 ge-0/0/47.0
ge-0/0/37.0 -> sa3-41 me0.0
ge-0/0/38.0 -> sa2-39-iSCSI ge-0/0/47.0
ge-0/0/39.0 -> sa2-39-iSCSI me0.0
ge-0/0/40.0 -> sa1-41 ge-0/0/47.0
ge-0/0/41.0 -> sa1-41 me0.0

This is being run against a Juniper EX2200 connected mostly to other Juniper EX2200 switches, along with a couple of Dell PowerConnects (3548s or 5324s) and a DLink DES-1210-28P.

[dave@store01 ~]$ mrrogers -s sa3-37
(731) ge-1/0/43.0 -> sa4-39 ge-0/0/9.0

[dave@store01 ~]$ mrrogers -s -p sa3-37
(731) ge-1/0/43.0 -> sa4-39 ge-0/0/9.0 (560)

[dave@store01 ~]$ mrrogers -l 587 sa4-39
ge-0/0/32.0 -> sa6-41 ge-0/0/47.0


  • Dell switches store Ethernet Port in their PortDesc table instead of something useful. We happen to know that the PortID value is useful, so if we see the generic string "Ethernet" as the PortDesc, we'll use the value from the PortID instead.
  • I found a DLink that stores nothing in PortDesc, so if we find an empty PortDesc, we'll use PortID instead.
  • Initial public release


This script should really be named after a character from Sesame Street because
these are the people in your neighbourhood
in your neighbourhood
in your neigh-bour-hood yeah
these are the people in your neighbourhood
they're the people that you see
when you do lldp
they're the people that you see
each day
...but I can't remember which character was known for singing it (it might have been a bunch of them, so that would be confusing)… and I may have put too much thought into this. So to help you forget all this confusion, >>here's Bob singing it.
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt