Pulls or pushes configs and shows/statistics from network devices.
Designed for minimal configuration, few dependencies, and fast deployment either as a one off or with cron/Task Scheduler.
- Python 3.10+
- netmiko - Install via pip:
python3 -m pip install netmiko - requests - (Optional: For LibreNMS integration only) Install via pip
python3 -m pip install requests - strictyaml - (Optional: For YAML configuration file support only) Install via pip
python3 -m pip install strictyaml
There are multiple options for specifiying what devices to target
A device inventory is passed with -i/--inventory
The inventory file is in CSV or YAML format, depending on your needs.
CSV allows per device specification of credentials and device type. It is useful for a small number of devices in a heterogeneous environment.
Create a CSV with a header and 5 fields, hostname OR ip, username, password, secret, and device_type and fill each appropriately for your devices.
The device_type field must match a netmiko device_type.
The other option for manual inventory is YAML*, this allows grouping together devices to use the same sets of credentials and device_type.
This is recommended for small to medium deployments where the same credentials are used to access multiple devices. Specify 1 or more credential groups and link them to 1 or more device groups. It is possible to omit the "linking" step if you have only 1 credential group or one of the groups is named "default". It is also possible to specify a default device_type, but not required.
* NOTE: A subset of YAML called StrictYAML is actually used. This shouldn't matter in this application and helps avoid mistakes due to the poor design of YAML.
See the examples/ directory for each.
A JSON config file is used to connect to LibreNMS. Pass the config file with the -l/--librenms option.
You will need API access and an API key, read only permissions are suffcient.
The JSON file MUST specify the following:
hostString - hostname/ip of your LibreNMS instanceapi_keyString - LibreNMS API keyusernameString - network device login username (NOT LibreNMS)passwordString - network device password
Optional configuration options:
protocolString - either "http" or "https" the protocol to connect to LibreNMS with (default: https)tls_verifyboolean - controls certificate validation if HTTPS is used (default: True if HTTPS is the protocol)secretString - network device 'secret' (default: same as password)- filters List of Object (spec below) - filters to limit the data from LibreNMS
The filters section of the JSON file allows you to filter the response from LibreNMS to exclude certain devices. Filters section is a list of objects with a:
-field (the part of the response that is filtered on)
-qualifier either "EQ" or "LIKE" for exact match or regex match respectively
qualifieeseither a single string or list of strings that the filter will check the field againstinvertedboolean will invert the filtermust_match_allboolean will control wether the filter will stop on the first match or if all qualifiees must succeed.
There is no limit to the number of filters. A default filter is built into the program to filter devices with OSes that are obviously not useful (Windows, Linux, Proxmox, Vmware, APC, etc)
The examples directory has a sample of both CSV and LibreNMS config files
Select operating mode with --push/--pull and provide a jobfile with -j/--jobfile. A "save only" operating mode is offered for convenience with the --save-only option, this mode just saves the config and does not require a jobfile.
The jobfile is a simple text file with commands in it.
In Pull mode, the commands are run one by one in exec mode (for Cisco, other NOS will use their equivalent) and the output is saved per command. In Push mode, the commands are sent all at once as a config set to be ran sequentially in config mode (or other NOS equivalent), a log of the commands run and any output is saved.
A list of supported device types can be found here
Retrive configuration and status: python3 nosmct/nosmct.py -i examples/sample-inventory.csv -j examples/cisco-pull-example.txt --pull
Deploy configuration: python3 nosmct/nosmct.py -i examples/sample-inventory.csv -j examples/cisco-push-example.txt --push
Save configuration only: python3 nosmct/nosmct.py -i examples/sample-inventory.csv --save-only
To use LibreNMS integration, the same commands as above apply, just replace -i ... with -l examples/sample-librenms-config.json
Increase number of concurrent connections by adding the -t or --threads flag followed by a number. (default is 10)
Pass -q or --quiet to supress most output.
Debug options: pass --verbose or -v for increased logging. --debug-netmiko for even more logging (this is done per thread and sent to a log file in the output folder), and --no-preload to disable caching of the configuration files.