A scanner util for NetBox, because certain networks can be updated automagically. netbox-scanner
aims to create, update, and delete hosts (/32
) in NetBox, either discovered after network probes and imported from CSV files.
netbox-scanner
is compatible with Python 3.6+, and can be installed like this:
$ wget https://github.com/forkd/netbox-scanner/archive/master.zip
$ unzip netbox-scanner-master.zip -d netbox-scanner
$ cd netbox-scanner
$ pip install -r requirements.txt
$ python netbox-scanner/nbscanner
Note that netbox-scanner
will require Nmap and an instance of NetBox (tested under NetBox 2.4.4) ready to use.
To use netbox-scanner
as a script, simply run netbox-scanner/nbscanner
and it'll create its configuration file (.netbox-scanner.conf
) in your home folder:
$ python nbscanner
After that, you'll just need to edit that file with your environment settings and run the script again, and netbox-scanner
will do the following tasks:
- It will scan all networks defined in the configuration file.
- For each discovered host it will:
- If it is in NetBox, description is different, and
tag
is equal to that defined in the configuration file, description will be updated in NetBox. - If host is not in NetBox, it'll be created.
- If it is in NetBox, description is different, and
- The script will iterate through each network to find and delete any hosts registered in NetBox that did not respond to scan, and have the
tag
defined in the configuration file.
For instance, if some hosts in your monitored networks are eventually down, but you don't want netbox-scanner
to manage them, just make sure that they don't have the tag defined in the configuration file.
Of course, you can use cron
to automatically run nbscanner
.
netbox-scanner
have a configuration file with all parameters needed to scan networks and synchronize them to NetBox. By default, this file is located at user's home folder and is created when nbscanner
is executed for the first time. Before using nbscanner
you should edit that file and fill all variables according to your environment.
netbox-scanner
can import data from CSV files in the following format:
IP Address,Description
10.0.0.1,Gateway
10.0.0.2,NTP Server
...
Note that the first line is header, IP addresses aren't in CIDR notation (a /32
will be appended to all addresses automatically) and commas aren't accepted in description. You can import this file using the --csv
parameter, like this:
$ nbscanner --csv netbox.csv
netbox-scanner
is licensed under a MIT license --read LICENSE
file for more information.