joi, 16 martie 2017

Network Diagram D3js based on ISIS Database


Let's build one based on ISIS database.

https://github.com/cpmarvin/isis_db_parser

First you need something to get the isis database from a device( ie: junos) so lets use py-ez

clone rep from github:
root@lab:/usr/local/src# git clone https://github.com/cpmarvin/isis_db_parser.git
cd /usr/local/src/
python isis_get.py

This will log to the router , get the db and provide a dic for links with some information about metric and local/remote ip and local/remote interface index ( Junos specific). In my lab this is what i get ( this ( use print df1 )

     source        target metric          l_ip l_int          r_ip r_int
0  vrr1.pgt      bdr1.lab    500  81.91.194.52   335  81.91.194.53   345
1  vrr1.pgt      bdr1.lab    500  81.91.194.50   333  81.91.194.51   437
4  bdr1.lab  AGG1.INX.LAB     10  192.168.1.29   393  192.168.1.30   333

and the dict:
[{'r_ip': '81.91.194.53', 'l_int': '335', 'target': 'bdr1.lab', 'metric': '500', 'source': 'vrr1.pgt', 'r_int': '345', 'l_ip': '81.91.194.52'}, {'r_ip': '81.91.194.51', 'l_int': '333', 'target': 'bdr1.lab', 'metric': '500', 'source': 'vrr1.pgt', 'r_int': '437', 'l_ip': '81.91.194.50'}, {'r_ip': '192.168.1.30', 'l_int': '393', 'target': 'AGG1.INX.LAB', 'metric': '10', 'source': 'bdr1.lab', 'r_int': '333', 'l_ip': '192.168.1.29'}]


Once you have this you can use the d3js script ( https://github.com/cpmarvin/d3js )  , and build the diagram :

Features:
- zoom
- neighbour highlight
- filtering based on regexp node name
- show all link label
Small network diagram :
Neighbours highlight: