Goal
Query a bunch of switches via snmp, specifically their switching tables, and figure out how to draw a topology map from the resulting information.
Notes Pages
Now things get complicated. Four new things all at once: Python, Python snmp, Postgres, and Python Postgres.
First target achieved:
A python script that scans the arp table on the router and the switching table on all the switches, then loads the information into a postgres database. The script identifies the mac address for each script, and we can query the database for that mac address.
$ time python y2
Router scan: cisco-10
Scanning: 3c39t1-06 0:80:3e:a9:4a:ef
Scanning: 3c4005-01 0:20:9c:23:e2:70
Scanning: 3c42t1-02 0:18:6e:3d:1:42
Scanning: 3c42t1-01 0:f:cb:32:7f:40
Scanning: 3c39t1-02 0:80:3e:a7:17:a7
Scanning: cisco-10 0:f:90:f2:2e:c5
Scanning: 3c39t2-04 0:80:3e:a9:43:96
Scanning: 3c39t2-05 0:80:3e:a9:43:1f
Scanning: 3c39t2-01 0:80:3e:a9:39:1f
Scanning: 3c43t1-02 0:5:1a:a:30:e0
Scanning: 3c39t2-03 0:80:3e:bb:2b:2a
Scanning: 3c39t1-01 0:80:3e:a9:3a:af
Scanning: 3c43t1-01 0:4:b:fd:ae:a0real 0m51.099s
user 0m10.031s
sys 0m0.211sswitchdb=# select switch, destination from switchingtable where target = '0:f:90:f2:2e:c5'; switch | destination
-----------+-------------
3c39t1-06 | 37
3c4005-01 | 49
3c42t1-01 | 49
3c39t1-02 | 37
3c39t2-05 | 37
3c39t2-01 | 37
3c43t1-02 | 49
3c39t2-03 | 36
3c39t1-01 | 37
3c43t1-01 | 49
(10 rows)
This means we can run algorithm tests without having to snooze through a two minute data-gathering exercise first.
Start figuring out the connectivity
This is a graphing problem. Each switch is reachable through a collection of ports, each on other switches. One of these ports is the local neighbor.