mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-01 19:14:37 +02:00
more info in logs
This commit is contained in:
parent
f1327f2102
commit
3be564d967
@ -18,7 +18,7 @@ Another way is download from GitHub:
|
|||||||
Note that `netbox-scanner` will require Nmap and an instance of NetBox ready to use.
|
Note that `netbox-scanner` will require Nmap and an instance of NetBox ready to use.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
`netbox-scanner` can be used both in your programs or as a script to be used in shell. To use `netbox-scanner` as a script, edit `netbox-scanner/config.py` with your setup, and run the command below:
|
`netbox-scanner` can be used both in your Python programs or as a script. To use `netbox-scanner` as a script, edit `netbox-scanner/config.py` with your setup, and run the command below:
|
||||||
|
|
||||||
$ netbox-scanner.py
|
$ netbox-scanner.py
|
||||||
|
|
||||||
@ -26,11 +26,11 @@ Note that `netbox-scanner` will require Nmap and an instance of NetBox ready to
|
|||||||
|
|
||||||
1. It will scan all networks defined in `netbox-scanner/config.py` or via parameters.
|
1. It will scan all networks defined in `netbox-scanner/config.py` or via parameters.
|
||||||
2. For each discovered host it will:
|
2. For each discovered host it will:
|
||||||
1. If host is in NetBox, description is different, and tag is set as defined in `netbox-scanner/config.py/TAG`, it'll be updated.
|
1. If host is in NetBox, description is different, and `tag` is set as defined in `netbox-scanner/config.py/TAG`, it'll be updated.
|
||||||
2. If host is not in NetBox, it'll be created.
|
2. If host is not in NetBox, it'll be created.
|
||||||
3. It will iterate through each network to find and delete any hosts registered in NetBox that did not respond to scan, and have the tag `netbox-scanner/config.py/TAG`.
|
3. It will iterate through each network to find and delete any hosts registered in NetBox that did not respond to scan, and have the tag `netbox-scanner/config.py/TAG`.
|
||||||
|
|
||||||
This way, if some hosts in your networks that are monitored via `netbox-scanner` are eventually down, but you don't want to delete them, just make sure that it doesn't have the tag as set in `netbox-scanner/config.py/TAG`.
|
This way, if some hosts in your monitored networks are eventually down, but you don't want to delete them, just make sure that they doesn't have the `netbox-scanner/config.py/TAG` tag.
|
||||||
|
|
||||||
To see a list of all available parameters in `netbox-scanner.py`, simple use the `-h` option --please note that all parameters are optional, because all of them can be set using `netbox-scanner/config.py` file:
|
To see a list of all available parameters in `netbox-scanner.py`, simple use the `-h` option --please note that all parameters are optional, because all of them can be set using `netbox-scanner/config.py` file:
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ class NetBoxScanner(object):
|
|||||||
'''
|
'''
|
||||||
create = update = delete = undiscovered = duplicate = 0
|
create = update = delete = undiscovered = duplicate = 0
|
||||||
for net in networks:
|
for net in networks:
|
||||||
logging.info('scan: {}'.format(net))
|
|
||||||
hosts = self.scan(net)
|
hosts = self.scan(net)
|
||||||
|
logging.info('scan: {} ({} hosts discovered)'.format(net, len(hosts)))
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
try:
|
try:
|
||||||
nbhost = self.nbhandler('get', address=host['address'])
|
nbhost = self.nbhandler('get', address=host['address'])
|
||||||
@ -103,8 +103,8 @@ class NetBoxScanner(object):
|
|||||||
self.nbhandler('delete', nbhost=nbhost)
|
self.nbhandler('delete', nbhost=nbhost)
|
||||||
delete += 1
|
delete += 1
|
||||||
else:
|
else:
|
||||||
logging.info('undiscovered: {}'.format(
|
logging.info('undiscovered: {} "{}"'.format(
|
||||||
nbhost.address))
|
nbhost.address, nbhost.description))
|
||||||
undiscovered += 1
|
undiscovered += 1
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
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.3.0',
|
version='0.3.1',
|
||||||
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