The goal for this code is to get the information I need. Not consider any optimization and efficiency. Feel free to optimize it.
Get BGP advertised routes from Juniper MX and IOS-XR and push them to the remote InfluxDB. To easily compare routes from different PoPs all around the world and know which provider should be the main entrance point for the traffic.
- Add devices in the host file called hosts.
- Change variables in the host_var
ansible_user: "user" <=== Enter Your username on devices.
ansible_ssh_pass: "password" Enter <==== Your username on devices.
ansible_connection: "network_cli"
ansible_network_os: "cisco.iosxr.iosxr"
os: "xr"
peers:
1: ===> This should be unique when you add the new peer.
name: lab-A9K-ISP ===> This name would be the name of your measurement in the InfluxDB
ip: 192.168.2.1 ===> The BGP Peer IP.
- Run the ansible-playbook
ansible-playbook -i hosts influx_adv.yml
- Modify the information of InfluxDB in push_influx.py
influxdb_ip = '10.1.1.1'
username = 'agent'
password = '@g1nt'
database = 'advertisement'
- Install the packages
pip3 install influxdb
- Execute the Python code
python3 push_influx.py