Netbox reports - Check IOS running on devices

999 views
Skip to first unread message

Donnchadh Woods

unread,
Apr 16, 2019, 7:04:54 AM4/16/19
to NetBox
HI there,

Just wondering if anyone knows if this is possible with Netbox...

Netbox is running and can query device status via NAPALM.

Is it possible to run a report that checks the IOS on a group of devices and spits it out into a report ? 

Cheers,
Donnchadh. 

Adrian Kus

unread,
Apr 17, 2019, 12:36:22 PM4/17/19
to NetBox
We ended up running a python script that uses Napalm to grab the current IOS version of all the IOS devices in Netbox and saving it to a custom field. You can run reports based on that.

import pynetbox
from napalm import get_network_driver
driver = get_network_driver('ios')
nb = pynetbox.api(url="http://netbox.domain", token="api-token")

devices = nb.dcim.devices.filter(platform="cisco", status=1, has_primary_ip="True")

for i in devices:
    device = driver(i.name, 'username', 'password')
    try:
        device.open()
        facts = device.get_facts()
        device.close()
        rtr = nb.dcim.devices.get(name=i.name)
        rtr.custom_fields['version'] = facts['os_version']
        rtr.save()
    except:
        print("Error updating ",i.name," version")
        print("")

Donnchadh Woods

unread,
Apr 17, 2019, 4:43:48 PM4/17/19
to Adrian Kus, NetBox
Hi Adrian,
Ok awesome... that's great. Very cool.
Thanks for sharing. 
I will try this to more.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/5487f149-e4af-4c41-89a7-3cbf516bdd6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

doug barker

unread,
Apr 19, 2019, 8:36:32 AM4/19/19
to Donnchadh Woods, Adrian Kus, NetBox
This is awesome thanks for sharing 

Donnchadh Woods

unread,
Apr 23, 2019, 4:20:37 PM4/23/19
to doug barker, Adrian Kus, NetBox
Thanks Adrian..
Just got this working... Its brilliant.. 
Did you do anything similar to grab subnets from devices and add to Netbox by any chance ? 
New to python so I'm pretty limited at the mo..
Reply all
Reply to author
Forward
0 new messages