mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-21 04:44:37 +02:00
new script name: nbscanner
This commit is contained in:
parent
28c79221a4
commit
4a5c66a8be
12
README.md
12
README.md
@ -13,15 +13,15 @@ You can also download from GitHub:
|
|||||||
$ unzip netbox-scanner-master.zip -d netbox-scanner
|
$ unzip netbox-scanner-master.zip -d netbox-scanner
|
||||||
$ cd netbox-scanner
|
$ cd netbox-scanner
|
||||||
$ pip install -r requirements.txt
|
$ pip install -r requirements.txt
|
||||||
$ python netbox-scanner/netbox-scanner.py
|
$ python netbox-scanner/nbscanner
|
||||||
|
|
||||||
Note that `netbox-scanner` will require [Nmap](https://nmap.org/) and an instance of NetBox ready to use.
|
Note that `netbox-scanner` will require [Nmap](https://nmap.org/) and an instance of NetBox ready to use.
|
||||||
|
|
||||||
|
|
||||||
## Scanning the Network
|
## Scanning the Network
|
||||||
To use `netbox-scanner` as a script, simply run `netbox-scanner/netbox-scanner.py` and it'll create its configuration file (`.netbox-scanner.conf`) in your home folder:
|
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 netbox-scanner.py
|
$ 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:
|
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:
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ After that, you'll just need to edit that file with your environment settings an
|
|||||||
|
|
||||||
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.
|
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 `netbox-scanner`.
|
Of course, you can use `cron` to automatically run `nbscanner`.
|
||||||
|
|
||||||
|
|
||||||
## Configuration File
|
## Configuration File
|
||||||
`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 `netbox-scanner.py` is executed for the first time. Before using `netbox-scanner.py` you should edit that file and fill all variables according to your environment.
|
`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.
|
||||||
|
|
||||||
|
|
||||||
## Importing from CSV File
|
## Importing from CSV File
|
||||||
@ -50,7 +50,7 @@ Of course, you can use `cron` to automatically run `netbox-scanner`.
|
|||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
$ netbox-scanner.py --csv netbox.csv
|
$ nbscanner --csv netbox.csv
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -187,12 +187,12 @@ class NetBoxScanner(object):
|
|||||||
hosts = []
|
hosts = []
|
||||||
with open(csvfile,'r') as f:
|
with open(csvfile,'r') as f:
|
||||||
next(f)
|
next(f)
|
||||||
hosts = [(f'{data[0]}/32',data[1]) for data in
|
hosts = [(data[0],data[1]) for data in
|
||||||
reader(f,delimiter=',')]
|
reader(f,delimiter=',')]
|
||||||
|
|
||||||
for s in self.stats:
|
for s in self.stats:
|
||||||
self.stats[s] = 0
|
self.stats[s] = 0
|
||||||
parsing = self.parser([h[0] for h in hosts])
|
parsing = self.parser([f'{h[0]}/32' for h in hosts])
|
||||||
if parsing:
|
if parsing:
|
||||||
self.logger('mistyped', badnets=parsing)
|
self.logger('mistyped', badnets=parsing)
|
||||||
return False
|
return False
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='netbox-scanner',
|
name='netbox-scanner',
|
||||||
version='0.7.1',
|
version='0.7.2',
|
||||||
author='José Lopes de Oliveira Jr.',
|
author='José Lopes de Oliveira Jr.',
|
||||||
author_email='jlojunior@gmail.com',
|
author_email='jlojunior@gmail.com',
|
||||||
description='A scanner util for NetBox',
|
description='A scanner util for NetBox',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user