GithubHelp home page GithubHelp logo

lopes / netbox-scanner Goto Github PK

View Code? Open in Web Editor NEW
152.0 8.0 37.0 83 KB

A scanner util for NetBox

License: MIT License

Python 96.55% Shell 3.45%
netbox netbox-scanner network networking nmap cisco cisco-prime netxms xml api

netbox-scanner's Introduction

netbox-scanner

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 by network scans and synchronized from other sources.

I know it's no more a scanner since version 2, because the focus now is to synchronize different databases to NetBox, so a better name would be netbox-sync.

Installation

netbox-scanner is compatible with Python 3.7+, and can be installed like this:

$ wget https://github.com/lopes/netbox-scanner/archive/master.zip
$ unzip netbox-scanner-master.zip -d netbox-scanner
$ cd netbox-scanner
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

After installation, use the netbox-scanner.conf file as an example to create your own and put this file in /opt/netbox or prepend its name with a dot and put it in your home directory --~/.netbox-scanner.conf. Keep reading to learn more about configuration.

Starting with Netbox v2.9.0 there are changes to the way tags are created. You must go into the web UI and explicity create a tag for each module you are planning to use here. So for example, if you want to use the nmap module, you have to create a Netbox tag called 'nmap' before you can successfully use it.

Quick Start

  1. Clone the repo and install the dependencies as shown above.
  2. Move the netbox-scanner.conf file to your Netbox directory (/opt/netbox) and fill out the variables according to your setup. Don't forget to change the path to match where you put this repo under [NMAP].path.
  3. Go to the samples subdirectory of this repo and execute ./nmap-scan.sh to get a first look at the behavior of this project.

Basics

netbox-scanner reads a user-defined source to discover IP addresses and descriptions, and insert them into NetBox. To control what was previously inserted, netbox-scanner adds tags to each record, so it will know that that item can be handled. In order to guarantee the integrity of manual inputs, records without such tags will not be updated or removed.

It is important to note that if netbox-scanner cannot define the description for a given host, then it will insert the string defined in the unknown parameter. Users can change those names at their own will.

For NetBox access, this script uses pynetbox --worth saying that was tested under NetBox v2.6.7.

Garbage Collection

If the user marked the cleanup option to yes, then netbox-scanner will run a garbage collector after the synchronization finishes. Basically, it will get all IP addresses recorded in NetBox under the same tag. Then, both lists will be compared: the one just retrieved from NetBox and the list that was synced. Hosts in the first list that don't appear in the second list will be deleted.

Configuration

Users can interact with netbox-scanner by command line and configuration file. The latter is pretty simple and straight forward: the only parameter accepted is the module you want to use.

The configuration file (netbox-scanner.conf) is where netbox-scanner looks for details such as authentication data and path to files. This file can be stored on the user's home directory or on /opt/netbox, but if you choose the first option, it must be a hidden file --.netbox-scanner.conf.

Remember that netbox-scanner will always look for this file at home directory, then at /opt/netbox, in this order. The first occurrence will be considered.

Modules

Since version 2.0, netbox-scanner is based on modules. This way, this program is just a layer that takes data from one source and inputs in NetBox. Each module is a file inside the nbs directory and is imported by the main script to retrieve data. This data comes always as a 2-dimension array of tuple IP address, description:

[('10.0.1.1', 'Gateway'), ('10.0.1.2', 'Server'), ('10.0.1.64', 'Workstation'), ...]

Nmap Module

Performing the scans is beyond netbox-scanner features, so you must run Nmap and save the output as an XML file using the -oX parameter. Since this file can grow really fast, you can scan each network and save it as a single XML file. You just have to assure that all files are under the same directory before running the script --see samples/nmap.sh for an example.

To properly setup this module, you must inform the path to the directory where the XML files reside, define a tag to insert to discovered hosts, and decide if clean up will take place. Tested on Nmap v7.80.

Prime Module

This script accesses Prime through RESTful API and all routines are implemented here. Users only have to point to Prime's API, which looks like https://prime.domain/webacs/api/v4/, inform valid credentials allowed to use the API, and fill the other variables, just like in Nmap.

It is important to note everything was tested on Cisco Prime v3.4.0, using API v4. It was noticed that when trying to retrieve access points data, Prime requires more privileges, so you must explicitly inform that you wish this by using Prime().run(access_points=True).

NetXMS Module

This module reads the full list of NetXMS' objects and searches for IPv4 addresses discarding loopback addresses. Unfortunately, NetXMS API is not well documented and it is quite different from other APIs, since it doesn't paginate and uses cookies for authentication. This way, querying NetXMS can take a couple of minutes depending on the number of records and it can downgrade the system.

Tests

Some basic tests are implemented under tests. This directory comes with a shell script to run all the tests at once, but before running it, remember to setup some environment variables required by them, such as NETBOX_ADDRESS and NMAP_PATH.

The script contains a list of all variables, but if you do not want to hardcode passwords, just make sure to export such variables in your shell and properly comment those lines.

New Modules

New modules should be implemented as a new file with the name of the module, for instance nbs/netxms.py. In this case, a class NetXMS should be created in this file with a method run. Finally, in netbox-scanner.py, a function cmd_netxms should be created to execute the just created class, and another option should be created both in the argument parsing section and in the if structure inside the main block.

Contributors

License

netbox-scanner is licensed under an MIT license --read LICENSE file for more information.

netbox-scanner's People

Contributors

bile0026 avatar dependabot[bot] avatar lopes avatar ndom91 avatar roterschnee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbox-scanner's Issues

No hosts.. wrong path?

This is the result I get.. don't know why
/netbox/netbox/netbox-scanner$ python3 netbox-scanner.py nmap
started: 0 hosts
finished: .0 +0 ~0 -0 !0

What Ports Are Used For Discovery

Hello,

Can you please confirm what ports are actually scanned in order to find the alive hosts on the network? This would be important what ports have to be allowed on the firewalls in order to let the application run properly.

Thanks and Regards

Addresses not in proper prefix after scanning

EDIT: See PR #7

Hi,

thanks for this script, it's working great.
Only issues I have is that the Addresses which are found are not getting added into any prefix.
Looks like this is happening because there is no VRF added to the addresses.

Is there any way we can associate VRFs to the scanned subnets which will then be added to the addresses?
Also there are almost no hostnames or such added to the description. Can we maybe have an option to add vendor names to the description (from mac addresses)?

Thank you in advance. I'll try to find a way myself with my very very limited python skills, I'd buy you a beer or two If you can help out though! :)

Move config file

Can I move the config file to /opt/netbox? If so how do direct nbscanner to do so? I don't see much in the way of a --help.

Could not open requirements file

I keep getting the error "ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

I am a little Linux illiterate so I might be missing something easy.
5-23-2022 11-43-48 AM

netbox-scanner.py creates IP Addresses, does not show up in Netbox

First time posting, so take it easy on me ;)

I've gotten pretty far in the setup of netbox-scanner, but am running into an issue on the last mile. Running 'netbox-scanner.py nmap' will successfully log that the records are being created from the .xml files in my defined scans folder:

created: 10.110.38.91/32 "unknown_hostname"
created: 10.110.38.100/32 "doesn't matter"
created: 10.110.50.2/32 "unknown_hostname"
created: 10.110.50.6/32 "doesn't matter"
created: 10.110.50.10/32 "unknown_hostname"
created: 10.110.50.12/32 "doesn't matter"

When looking at the NetBox web interface, I see no updates. I double check the DB and can see there are no updates there either. I know my host and token defined in my .conf are valid since if I play around with that, I get errors. I tried to read through the init.py file in the nbs folder for clues on where this could be failing, but am not having much luck :(. Hopefully it's something stupid - any insight would be appreciated.

I am running the latest version of Netbox, v2.11.4

Traceback on Ubuntu 18.04.2 LTS

Hi

I'm getting the following traceback error on Ubuntu 18.04.2
I installed netbox-scanner by pip3 as per the instructions, and have checked the requirements have been installed. I am running Python 2.7.15rc1

any ideas?

Traceback (most recent call last): File "nbscanner", line 10, in <module> from urllib3 import disable_warnings ImportError: No module named urllib3

SSH/snmp functionality

Hello,

currently I'm trying to figure out if Netbox Scanner is able to login to devices (Linux or Windows VM, Cisco and other network devices) and retrieve FQDN. (Maybe Scanner is able to perform this by querying DNS?)

For instance I'm sure that FQDN could be also inserted into Netbox DB after the scan. Although I haven't found any detailed explanation if anything needs to be done from my side in config file. (I can see that additional host have been found but they are marked as unkown host and no DNS name) Only tacacs config which implies that netbox scanner should be able to login to devices?

Once looking into code I found that TACACS config is used in:

def get_description(self, address, name, cpe):
    '''Define a description based on hostname and CPE'''
    if name:
        return name
    else:
        c = CPE(cpe[0], CPE.VERSION_2_3)
        vendor = c.get_vendor()[0]
        if self.tacacs and vendor == 'cisco':
            try:
                client = SSHClient()
                client.set_missing_host_key_policy(AutoAddPolicy())
                client.connect(address, username=self.tacacs['user'],
                    password=self.tacacs['password'])
                stdin,stdout,stderr = client.exec_command(self.tacacs['command'])
                return '{}:{}'.format(vendor.lower(),
                    re.search(self.tacacs['regex'],
                    str(stdout.read().decode('utf-8'))).group(self.tacacs['regroup']))
            except (AuthenticationException, SSHException,
                NoValidConnectionsError, TimeoutError,
                ConnectionResetError):
                pass
        return '{}.{}.{}'.format(c.get_vendor()[0], c.get_product()[0],
            c.get_version()[0])

So it seems that only Cisco devices are supported right now? correct me if I'm wrong.

To sum up:

  1. Is Netbox Scanner capable adding FQDN info into Netbox DB?
  2. Is Netbox Scanner capable logging into devices? currently Cisco?
  3. Is netbox Scanner capable of using SSH and command list of specific devices to retrieve and store info into Netbox DB?
  4. SNMP queries?

different configs for cron run

Is it possible to use different configs at different sheduled cron tasks?
Some Networks must scanned often and some less often.

Script does not delete "down" hosts

Hi!
Through this point:
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.
i can't understand, how script understands that host is down and script should delete this host.
I tried some scenarios, but nothing works.

Version 2.0

After some time using this script, I think the best approach is to create a modular environment where "plugins" can be written to scan other tools such as Nmap outputs, PRTG and NetXMS and sync to NetBox. Since other tools have a more reliable database of IP and descriptions, the idea is to sync that data to NetBox, which will lead to a 2.0 version.

For instance, when using Nmap the configuration file (~/.netbox-scanner.conf) will be read to load the parameters for NetBox and the file containing the scan, thus the sync will start. This means the users will need to run Nmap apart (like using cron and Shell Script) and use the output file as input to netbox-scanner. Command line will be like:

$ netbox-scanner [MODULE]
# where MODULE can be nmap, prime, netxms, prtg, or any other existing module.

This new version will also focus on using the Python Standard Library, to reduce security issues, and to streamline installation. Needless to say this version will be compatible to Python 3.8+, although older versions could be compatible too.

Hope you guys have patience, since I'm trying to do this in my spare time, which is scarce due to other projects, but I'll do my best. The objective of this new version is to create the main environment, along with Nmap e Cisco Prime modules. I'll try to create the PRTG and NetXMS modules too, but don't take it as a promise, okay?

  • Create command line script for the main environment
  • Improve the search for the configuration file
  • Create Nmap module
  • Link Nmap module to main environment
  • Write tests
  • Update documentation
  • Create Cisco Prime module

Suggestions are welcome.

Updates

  • 2020.05.25: added the idea to permit the configuration file to be put on ~ or in /opt/netbox. netbox-scanner will look for this file in the first directory and if it's not there, it'll search on the second directory.

nm[host]['osmatch'] does not work

In the function "def scan(self, network):" i get the following error:

"KeyError: 'osmatch'"

For this reason, in the function is the except part called and every host has as Description "unknown host".

Here is a example of the nm[host] variable:

{'hostnames': [{'name': 'XXX', 'type': 'PTR'}], 'addresses': {'ipv4': 'XXX', 'mac': '00:50:56:01:0A:CF'}, 'vendor': {'00:50:56:01:0A:CF': 'VMware'}, 'status': {'state': 'up', 'reason': 'arp-response'}}

We see that there is no Key like osmatch there.

pip install not working

Thank you for this project.

On an Ubuntu 20.04 LXC I get the following error when executing pip install -r requirements.txt :

Building wheels for collected packages: pynetbox
  Building wheel for pynetbox (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /root/netbox-scanner/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q7v9tk77/pynetbox/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q7v9tk77/pynetbox/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-m46mij1y
       cwd: /tmp/pip-install-q7v9tk77/pynetbox/
  Complete output (32 lines):
  WARNING: The wheel package is not available.
  WARNING: The wheel package is not available.
  WARNING: The wheel package is not available.
  WARNING: The wheel package is not available.
  /tmp/pip-install-q7v9tk77/pynetbox/.eggs/setuptools_scm-6.3.2-py3.8.egg/setuptools_scm/integration.py:16: RuntimeWarning:
  ERROR: setuptools==44.0.0 is used in combination with setuptools_scm>=6.x
  
  Your build configuration is incomplete and previously worked by accident!
  
  
  This happens as setuptools is unable to replace itself when a activated build dependency
  requires a more recent setuptools version
  (it does not respect "setuptools>X" in setup_requires).
  
  
  setuptools>=31 is required for setup.cfg metadata support
  setuptools>=42 is required for pyproject.toml configuration support
  
  Suggested workarounds if applicable:
   - preinstalling build dependencies like setuptools_scm before running setup.py
   - installing setuptools_scm using the system package manager to ensure consistency
   - migrating from the deprecated setup_requires mechanism to pep517/518
     and using a pyproject.toml to declare build dependencies
     which are reliably pre-installed before running the build tools
  
    warnings.warn(
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help
  
  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for pynetbox
  Running setup.py clean for pynetbox
Failed to build pynetbox
Installing collected packages: certifi, chardet, idna, urllib3, requests, six, pynetbox
    Running setup.py install for pynetbox ... done
Successfully installed certifi-2020.4.5.1 chardet-3.0.4 idna-2.9 pynetbox-4.3.1 requests-2.23.0 six-1.15.0 urllib3-1.25.9

Any ideas how I can get this project installed and working in the latest NetBox?

nothing is imported into netbox

im running python3 netbox-scanner.py nmap

its saying started 0 hosts.. the samples i ran and it went out and did nmap discovery , created the xml file and everything.
am i literally doing it wrong?

nmap scan not iterating through subnets

Couldn't find this issue posted in the open or closed issues so hopefully someone can assist me.

Resolved an issue where I was receiving a traceback when attempting to run netbox-scanner.py nmap. (i had to manually make the "logs" directory)

Now when I run the netbox-scanner.py nmap command it returns almost immediately "0 hosts scanned 0 0 0 0 0"
I have prefixes defined in the config under [SCAN].

I am able to scan using the nmap command just fine.

Any suggestions or assistance into what i'm doing wrong?

nmap: duplicated entries detected that I cannot explain

Hi
First thanks for this module, it is really helpful.
I am running it using an nmap ouput, but almost all the entries are detected as 'duplicated' even if I don't have any entry in Netbox before trying to import them.
So are there some cache mechanisms somewhere, or something I should make sure to check to identify the reasons of those duplicates?
Here is the output:

started: 24 hosts created: 10.0.2.2/32 "_gateway" created: 10.0.2.3/32 "autodiscovered:netbox-scanner" duplicated: 10.0.2.4/32 duplicated: 10.0.2.15/32 duplicated: 10.0.0.1/32 duplicated: 10.0.0.2/32 duplicated: 10.0.0.3/32 duplicated: 10.0.0.4/32 duplicated: 10.0.0.5/32 duplicated: 10.0.0.6/32 duplicated: 10.0.0.9/32 duplicated: 10.0.0.10/32 duplicated: 10.0.0.20/32 duplicated: 10.0.0.220/32 duplicated: 10.0.0.221/32 duplicated: 10.0.0.222/32 duplicated: 10.0.0.253/32 duplicated: 10.0.0.210/32 duplicated: 172.28.128.1/32 duplicated: 172.28.128.2/32 duplicated: 172.28.128.220/32 duplicated: 172.28.128.221/32 duplicated: 172.28.128.222/32 duplicated: 172.28.128.210/32 finished: .0 +2 ~0 -0 !22

Another question, is that nmap retrieves a lot more info than only IP/hostname, and it seems that the script does take into acccount those extra information. Are there any plan to create automatically the 'vendors', etc ... or would you recommend using another tool, and which one?

thanks.

Getting Traceback

Traceback (most recent call last):
  File "netbox-scanner/nbscanner", line 13, in <module>
    from nbscanner import NetBoxScanner
  File "/home/jsummers/netbox-scanner/netbox-scanner/nbscanner.py", line 195
    parsing = self.parser([f'{h[0]}/32' for h in hosts])

Mistake in NetBoxScanner class

Issue

When I tried to create ip-address netbox with below:

            self.netbox.ipam.ip_addresses.create(
                address=host[0],
                tags=[{"name": self.tag}],
                # dns_name=host[1],
                description=host[1]
            )

I got a error:
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'tags': ['All list items must be of string type.']}

How does it solve?

we have to change dict inside list to simple list without dict
#tags=[{"name": self.tag}],
with
tags=[self.tag],

Proof

изображение

KeyError

Hello Lopes,

I installed the netbox-scanner, but when I run the script, it gives an error.

Maybe because I didn't set it up right.

The error is as follows:

2020-09-28_11h34_52

Please, can anyone help me.

[Feat] Adding reverse DNS info to DNS name in NetBox

Hi,
thank you for the neat script.
Do you think that's possible to add the reverse DNS info discovered by the nmap scan as DNS Name in the host information passed to NetBox?
I'm new with Python and NetBox, so I've not yet tried to do it myself.
And before starting the endeavor, know if at least it's possible could be useful ;-)

Thanks again, regards

  • Manuel B.

Compatibility to netbox 2.9

I´ve been trying to integrate into a fresh install of netbox 2.9.2, but it seems that the API has changed a bit.
This is the error I keep getting on trying to use nmap functionalities, both in the pre-2.0 versions and the actual netbox-scanner:
"
Traceback (most recent call last):
File "netbox-scanner/nbscanner", line 75, in
nbs.sync(networks)
File "/opt/netbox-scanner/netbox-scanner/nbscanner.py", line 228, in sync
self.sync_network(network)
File "/opt/netbox-scanner/netbox-scanner/nbscanner.py", line 157, in sync_netw ork
self.sync_host(host)
File "/opt/netbox-scanner/netbox-scanner/nbscanner.py", line 144, in sync_host
tags=[self.tag], description=host[1])
File "/usr/local/lib/python3.6/dist-packages/pynetbox/core/endpoint.py", line 279, in create
).post(args[0] if args else kwargs)
File "/usr/local/lib/python3.6/dist-packages/pynetbox/core/query.py", line 295 , in post
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'tags': [['Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: auto']]}
"
The actual version of netbox-scannet passes nmap value instead of auto.
Maybe an update of the pynetbox to the current version may fix the issue.
Best Regards,
Lincoln

Getting Traceback Centos 7

Traceback (most recent call last):
File "nbscanner", line 5, in
from configparser import ConfigParser
ImportError: No module named configparser

I have installed the following -

pip install configparser
Collecting configparser
Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz
Installing collected packages: configparser
Running setup.py install for configparser ... done
Successfully installed configparser-3.5.0

But still running into that same issue.

error when executing nmap-scan.sh

I am trying to run this as the netbox user. Should I be doing this with root or another user w/ sudo privileges? I am running this on AlmaLinux 8.4.

[ameyer@dcim001 samples]$ sudo su - netbox
Last login: Thu Oct 21 11:28:28 CDT 2021 on pts/0
[netbox@dcim001 ~]$ cd netbox-scanner-2/samples/
[netbox@dcim001 samples]$ sh nmap-scan.sh
nmap-scan.sh: line 19: NETWORKS: command not found
Traceback (most recent call last):
  File "../netbox-scanner.py", line 80, in <module>
    cmd_nmap(scanner)
  File "../netbox-scanner.py", line 55, in cmd_nmap
    h.run()
  File "/opt/netbox-3.0.7/netbox-scanner-2/nbs/nmap.py", line 13, in run
    for f in os.listdir(self.path):
FileNotFoundError: [Errno 2] No such file or directory: 'samples/nmap'
tar: *.xml: Cannot stat: No such file or directory
tar (child): Cannot connect to nmap-21.10.21T11: resolve failed
tar: Child returned status 128
tar: Error is not recoverable: exiting now
[netbox@dcim001 samples]$

pynetbox.lib.query.RequestError: The request failed with code 400 Bad Request

I get this error both in Centos 7.6 and in a container running debian and python 3.7.3

My netbox is versionn 2.5.8

root@b456e5f91474:~/netbox-scanner# pip freeze

asn1crypto==0.24.0
bcrypt==3.1.4
certifi==2018.8.24
cffi==1.11.5
chardet==3.0.4
cpe==1.2.1
cryptography==2.3.1
idna==2.7
netaddr==0.7.19
paramiko==2.4.2
pyasn1==0.4.4
pycparser==2.19
PyNaCl==1.3.0
pynetbox==3.4.6
python-nmap==0.6.1
requests==2.19.1
six==1.11.0
urllib3==1.23

root@b456e5f91474:~/netbox-scanner# python --version
Python 3.7.3

Here is the stack trace:

root@b456e5f91474:~/netbox-scanner# python netbox-scanner-master/netbox-scanner/nbscanner
Traceback (most recent call last):
  File "netbox-scanner-master/netbox-scanner/nbscanner", line 75, in <module>
    nbs.sync(networks)
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 223, in sync
    self.sync_network(network)
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 157, in sync_network
    self.sync_host(host)       
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py", line 131, in sync_host
    nbhost = self.netbox.ipam.ip_addresses.get(address=host[0])
  File "/usr/local/lib/python3.7/site-packages/pynetbox/lib/endpoint.py", line 157, in get
    filter_lookup = self.filter(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/lib/endpoint.py", line 247, in filter
    for i in req.get()
  File "/usr/local/lib/python3.7/site-packages/pynetbox/lib/query.py", line 240, in get
    return req_all(self.url)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/lib/query.py", line 222, in req_all
    req = make_request(url)
  File "/usr/local/lib/python3.7/site-packages/pynetbox/lib/query.py", line 219, in make_request
    raise RequestError(req)
pynetbox.lib.query.RequestError: The request failed with code 400 Bad Request

requirements mismatch: urllib3==1.26.5 vs requests==2.23.0

`ERROR: Cannot install -r requirements.txt (line 5) and urllib3==1.26.5 because these package versions have conflicting dependencies.

The conflict is caused by:
The user requested urllib3==1.26.5
requests 2.23.0 depends on urllib3!=1.25.0, !=1.25.1, <1.26 and >=1.21.1
`

It seems you can't have both urllib3 1.26.5 and requests 2.23.0 at the same time.

Traceback error on netbox 2.10.1

Getting this on a brand new install of both netbox and netbox-scanner. Is 2.10.1 supported?

root@HOST netbox-scanner]# python3 netbox-scanner.py nmap
Traceback (most recent call last):
File "netbox-scanner.py", line 62, in
format='%(asctime)s\tnetbox-scanner\t%(levelname)s\t%(message)s'
File "/usr/local/lib/python3.7/logging/init.py", line 1898, in basicConfig
h = FileHandler(filename, mode)
File "/usr/local/lib/python3.7/logging/init.py", line 1087, in init
StreamHandler.init(self, self._open())
File "/usr/local/lib/python3.7/logging/init.py", line 1116, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/opt/netbox-scanner/logs/netbox-scanner-2021-01-12T16:16:23.599360.log'

[root@HOST netbox-scanner]#

install issues

I just tried to install this on CentOS 7.5, and am having some issues:

# pip3 install netbox-scanner
WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user instead.
Collecting netbox-scanner
Downloading https://files.pythonhosted.org/packages/68/d5/e36874a35694a08bcd14f1b2c10b4ce8e274eb04d470d5a23f4e0782ae4c/netbox-scanner-0.7.2.tar.gz
Installing collected packages: netbox-scanner
Running setup.py install for netbox-scanner ... done
Successfully installed netbox-scanner-0.7.2
[root@simon-test ~]# python nbscanner
python: can't open file 'nbscanner': [Errno 2] No such file or directory
[root@simon-test ~]# find / -name nbscanner
[root@simon-test ~]# find / -name netbox-scanner
/usr/local/lib/python3.6/site-packages/netbox-scanner
[root@simon-test ~]# cd /usr/local/lib/python3.6/site-packages/netbox-scanner
[root@simon-test netbox-scanner]# ls -al
total 28
drwxr-xr-x. 3 root root 78 Jan 6 15:41 .
drwxr-xr-x. 127 root root 8192 Jan 6 15:41 ..
-rw-r--r--. 1 root root 1053 Oct 29 2018 dac.py
-rw-r--r--. 1 root root 0 Oct 29 2018 _init
.py
-rw-r--r--. 1 root root 9271 Oct 29 2018 nbscanner.py
drwxr-xr-x. 2 root root 95 Jan 6 15:41 _pycache_
[root@simon-test netbox-scanner]# python ./nbscanner.py
File "./nbscanner.py", line 195
parsing = self.parser([f'{h[0]}/32' for h in hosts])
^
SyntaxError: invalid syntax
_

OK, maybe something wrong with the pip version, let's try manually installing..

# wget https://github.com/forkd/netbox-scanner/archive/master.zip
--2020-01-06 15:50:30-- https://github.com/forkd/netbox-scanner/archive/master.zip
Resolving github.com (github.com)... 192.30.253.113
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/forkd/netbox-scanner/zip/master [following]
--2020-01-06 15:50:30-- https://codeload.github.com/forkd/netbox-scanner/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.253.121
Connecting to codeload.github.com (codeload.github.com)|192.30.253.121|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘master.zip’

[ <=>                                                                                                                            ] 9,054       --.-K/s   in 0.02s   

2020-01-06 15:50:30 (398 KB/s) - ‘master.zip’ saved [9054]

[root@simon-test ~]# unzip netbox-scanner-master.zip -d netbox-scanner
unzip: cannot find or open netbox-scanner-master.zip, netbox-scanner-master.zip.zip or netbox-scanner-master.zip.ZIP.

[root@simon-test ~]# unzip master.zip -d netbox-scanner
Archive: master.zip
02d573d
creating: netbox-scanner/netbox-scanner-master/
inflating: netbox-scanner/netbox-scanner-master/.gitignore
inflating: netbox-scanner/netbox-scanner-master/LICENSE
inflating: netbox-scanner/netbox-scanner-master/README.md
creating: netbox-scanner/netbox-scanner-master/netbox-scanner/
extracting: netbox-scanner/netbox-scanner-master/netbox-scanner/init.py
inflating: netbox-scanner/netbox-scanner-master/netbox-scanner/dac.py
inflating: netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner
inflating: netbox-scanner/netbox-scanner-master/netbox-scanner/nbscanner.py
inflating: netbox-scanner/netbox-scanner-master/requirements.txt
inflating: netbox-scanner/netbox-scanner-master/setup.py
[root@simon-test ~]# cd netbox-scanner
[root@simon-test netbox-scanner]# pip install -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try pip install --user instead.
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
[root@simon-test netbox-scanner]# cd netbox-scanner-master
[root@simon-test netbox-scanner-master]# pip install -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try pip install --user instead.
Collecting asn1crypto==0.24.0 (from -r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting bcrypt==3.1.6 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/d0/79/79a4d167a31cc206117d9b396926615fa9c1fdbd52017bcced80937ac501/bcrypt-3.1.6-cp34-abi3-manylinux1_x86_64.whl (55kB)
100% |████████████████████████████████| 61kB 2.9MB/s
Collecting certifi==2019.3.9 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
100% |████████████████████████████████| 163kB 3.6MB/s
Collecting cffi==1.12.2 (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/20/f7/87b62a8895bf7c93e907b05b97bc4459c81a38a61151f03a6eae13d863aa/cffi-1.12.2-cp36-cp36m-manylinux1_x86_64.whl (428kB)
100% |████████████████████████████████| 430kB 2.3MB/s
Requirement already satisfied: chardet==3.0.4 in /usr/lib/python3.6/site-packages (from -r requirements.txt (line 5))
Collecting cpe==1.2.1 (from -r requirements.txt (line 6))
Downloading https://files.pythonhosted.org/packages/cd/8a/1dc2644a1fe6049cff29accd1d5830ef2b51b8c71b95b187a59f884777c7/cpe-1.2.1.tar.gz (2.2MB)
100% |████████████████████████████████| 2.2MB 635kB/s
Collecting cryptography==2.6.1 (from -r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/5b/12/b0409a94dad366d98a8eee2a77678c7a73aafd8c0e4b835abea634ea3896/cryptography-2.6.1-cp34-abi3-manylinux1_x86_64.whl (2.3MB)
100% |████████████████████████████████| 2.3MB 592kB/s
Collecting idna==2.8 (from -r requirements.txt (line 8))
Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 2.9MB/s
Collecting paramiko==2.4.2 (from -r requirements.txt (line 9))
Downloading https://files.pythonhosted.org/packages/cf/ae/94e70d49044ccc234bfdba20114fa947d7ba6eb68a2e452d89b920e62227/paramiko-2.4.2-py2.py3-none-any.whl (193kB)
100% |████████████████████████████████| 194kB 4.2MB/s
Collecting pyasn1==0.4.5 (from -r requirements.txt (line 10))
Downloading https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl (73kB)
100% |████████████████████████████████| 81kB 8.4MB/s
Requirement already satisfied: pycparser==2.19 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 11))
Requirement already satisfied: PyNaCl==1.3.0 in /usr/local/lib64/python3.6/site-packages (from -r requirements.txt (line 12))
Collecting pynetbox==4.0.6 (from -r requirements.txt (line 13))
Downloading https://files.pythonhosted.org/packages/08/72/261842773f7f6a66379473eb76dd651117dcfaed0c1c15f4ee4e14b3d5f3/pynetbox-4.0.6.tar.gz (44kB)
100% |████████████████████████████████| 51kB 9.8MB/s
Collecting python-nmap==0.6.1 (from -r requirements.txt (line 14))
Downloading https://files.pythonhosted.org/packages/dc/f2/9e1a2953d4d824e183ac033e3d223055e40e695fa6db2cb3e94a864eaa84/python-nmap-0.6.1.tar.gz (41kB)
100% |████████████████████████████████| 51kB 8.8MB/s
Collecting requests==2.21.0 (from -r requirements.txt (line 15))
Downloading https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 8.5MB/s
Collecting six==1.12.0 (from -r requirements.txt (line 16))
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: urllib3==1.24.1 in /usr/lib/python3.6/site-packages (from -r requirements.txt (line 17))
Installing collected packages: asn1crypto, cffi, six, bcrypt, certifi, cpe, cryptography, idna, pyasn1, paramiko, requests, pynetbox, python-nmap
Found existing installation: cffi 1.13.2
Uninstalling cffi-1.13.2:
Successfully uninstalled cffi-1.13.2
Found existing installation: six 1.13.0
Uninstalling six-1.13.0:
Successfully uninstalled six-1.13.0
Found existing installation: bcrypt 3.1.7
Uninstalling bcrypt-3.1.7:
Successfully uninstalled bcrypt-3.1.7
Running setup.py install for cpe ... done
Found existing installation: cryptography 2.8
Uninstalling cryptography-2.8:
Successfully uninstalled cryptography-2.8
Found existing installation: pyasn1 0.4.8
Uninstalling pyasn1-0.4.8:
Successfully uninstalled pyasn1-0.4.8
Found existing installation: paramiko 2.6.0
Uninstalling paramiko-2.6.0:
Successfully uninstalled paramiko-2.6.0
Running setup.py install for pynetbox ... done
Running setup.py install for python-nmap ... done
Successfully installed asn1crypto-0.24.0 bcrypt-3.1.6 certifi-2019.3.9 cffi-1.12.2 cpe-1.2.1 cryptography-2.6.1 idna-2.8 paramiko-2.4.2 pyasn1-0.4.5 pynetbox-4.0.6 python-nmap-0.6.1 requests-2.21.0 six-1.12.0
[root@simon-test netbox-scanner-master]# ls
LICENSE netbox-scanner README.md requirements.txt setup.py
[root@simon-test netbox-scanner-master]# ls -al
total 20
drwxr-xr-x. 3 root root 118 May 14 2019 .
drwxr-xr-x. 3 root root 35 Jan 6 15:50 ..
-rw-r--r--. 1 root root 1203 May 14 2019 .gitignore
-rw-r--r--. 1 root root 1068 May 14 2019 LICENSE
drwxr-xr-x. 2 root root 76 May 14 2019 netbox-scanner
-rw-r--r--. 1 root root 2815 May 14 2019 README.md
-rw-r--r--. 1 root root 277 May 14 2019 requirements.txt
-rw-r--r--. 1 root root 657 May 14 2019 setup.py
[root@simon-test netbox-scanner-master]# cd netbox-scanner/
[root@simon-test netbox-scanner]# ls
dac.py init.py nbscanner nbscanner.py
[root@simon-test netbox-scanner]#
[root@simon-test netbox-scanner]# cd ..
[root@simon-test netbox-scanner-master]# python netbox-scanner/nbscanner
Traceback (most recent call last):
File "netbox-scanner/nbscanner", line 5, in
from configparser import ConfigParser
ImportError: No module named configparser

[root@simon-test netbox-scanner-master]# ls
LICENSE netbox-scanner README.md requirements.txt setup.py
[root@simon-test netbox-scanner-master]# python ./setup.py
File "./setup.py", line 11
SyntaxError: Non-ASCII character '\xc3' in file ./setup.py on line 11, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

So I'm lost at this point. I don't know how to configure or run this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.