From 4a5c66a8be2c1b204fb2dfb4804c534c95d88dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lopes?= Date: Mon, 29 Oct 2018 15:20:08 -0300 Subject: [PATCH] new script name: nbscanner --- README.md | 12 ++++++------ netbox-scanner/{netbox-scanner.py => nbscanner} | 0 netbox-scanner/nbscanner.py | 4 ++-- setup.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename netbox-scanner/{netbox-scanner.py => nbscanner} (100%) diff --git a/README.md b/README.md index 2c5e628..7f59afa 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,15 @@ You can also download from GitHub: $ unzip netbox-scanner-master.zip -d netbox-scanner $ cd netbox-scanner $ 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. ## 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: @@ -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. -Of course, you can use `cron` to automatically run `netbox-scanner`. +Of course, you can use `cron` to automatically run `nbscanner`. ## 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 @@ -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: - $ netbox-scanner.py --csv netbox.csv + $ nbscanner --csv netbox.csv ## License diff --git a/netbox-scanner/netbox-scanner.py b/netbox-scanner/nbscanner similarity index 100% rename from netbox-scanner/netbox-scanner.py rename to netbox-scanner/nbscanner diff --git a/netbox-scanner/nbscanner.py b/netbox-scanner/nbscanner.py index 5548f98..7712647 100644 --- a/netbox-scanner/nbscanner.py +++ b/netbox-scanner/nbscanner.py @@ -187,12 +187,12 @@ class NetBoxScanner(object): hosts = [] with open(csvfile,'r') as f: next(f) - hosts = [(f'{data[0]}/32',data[1]) for data in + hosts = [(data[0],data[1]) for data in reader(f,delimiter=',')] for s in self.stats: 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: self.logger('mistyped', badnets=parsing) return False diff --git a/setup.py b/setup.py index 0ec919b..9c9dfcd 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.md', 'r') as fh: setuptools.setup( name='netbox-scanner', - version='0.7.1', + version='0.7.2', author='José Lopes de Oliveira Jr.', author_email='jlojunior@gmail.com', description='A scanner util for NetBox',