Skip to main content

LibreNMS handler

PyPI image Downloads Black Bandit CodeQL

A Python library to interact with the LibreNMS API (v0).

The project aims to provide the user with as much information as if they were looking at the reference guide themselves.

I have not used it myself so I cannot endorse it, but a quick search shows that LibreNMSAPI has a similar goal with a different outlook. Consider checking it out if this project doesn't suit your needs!

Usage

The package is installed with the following package managers like so:

Pip

pip install librenms-handler

Pipenv

pipenv install librenms-handler

The following statement will initialise the chosen endpoint:

from librenms_handler.devices import Devices

devices = Devices(
    'https://librenms.example.com',
    'e4ef9234abab59a90628dd3f616a60b4'
)

NOTE: If you are using a self-signed certificate for your server, you can bypass the errors by passing the initialisation option verify=False.

Once done, a list of methods will be available to you such as devices.list_devices(). Upon operation, the method will execute and return the required request to your LibreNMS instance.

>>> devices.add_device('test_device', snmp_disable=True, force_add=True)
{'status': 'ok', 'message': 'Device test_device (13) has been added successfully'}
>>> devices.del_device('test')
{'status': 'ok', 'devices': [{'device_id': 13, 'inserted': '2021-03-13 15:56:19', 'hostname': 'test_device', 'sysName': '', 'ip': None, 'overwrite_ip': None, 'community': '', 'authlevel': None, 'authname': None, 'authpass': None, 'authalgo': None, 'cryptopass': None, 'cryptoalgo': None, 'snmpver': 'v2c', 'port': 161, 'transport': 'udp', 'timeout': None, 'retries': None, 'snmp_disable': 1, 'bgpLocalAs': None, 'sysObjectID': None, 'sysDescr': None, 'sysContact': None, 'version': None, 'hardware': '', 'features': None, 'location_id': None, 'os': 'ping', 'status': True, 'status_reason': '', 'ignore': 0, 'disabled': 0, 'uptime': None, 'agent_uptime': 0, 'last_polled': None, 'last_poll_attempted': None, 'last_polled_timetaken': None, 'last_discovered_timetaken': None, 'last_discovered': None, 'last_ping': None, 'last_ping_timetaken': None, 'purpose': None, 'type': 'server', 'serial': None, 'icon': 'images/os/ping.svg', 'poller_group': 0, 'override_sysLocation': 0, 'notes': None, 'port_association_mode': 1, 'max_depth': 0, 'disable_notify': 0, 'location': None, 'lat': None, 'lng': None, 'attribs': [], 'vrf_lite_cisco': []}], 'message': 'Removed device test_device\n', 'count': 1}

The output is exactly the same as if you were using Curl to make the requests.

Should you wish to use any other endpoint, the situation would be the same: from librenms_handler.endpoint import Endpoint

Environment variables

While initialising the handler, the following parameters are required. The handler first checks for the following environment variables, should you choose to use them.

Environment variable Description Type Example
LIBRENMS_URL Full URL to the target LibreNMS instance string https://librenms.example.com
LIBRENMS_TOKEN Token generated from LIBRENMS_URL/api-access string e4ef9234abab59a90628dd3f616a60b4

Endpoints

The progress of API endpoints are shown in their respective projects below: See Projects to track the progress of the endpoints or select individual ones below.

It is not possible to say when an endpoint is 'done', as they are being expanded as time goes on. Each function will have its own issue tracked, so you can search to see if implemented or not.

Endpoint Started
Alerts False
ARP True
Bills False
Device Groups True
Devices True
Inventory True
Locations True
Logs True
Port Groups False
Ports False
Routing False
Services False
Switching True
System True

Metadata

Release files for librenms-handler 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for librenms-handler 0.4.3
File Size Uploaded Provenance
librenms_handler-0.4.3.tar.gz 13.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for librenms-handler 0.4.3
File Interpreter ABI Platform
librenms_handler-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / librenms_handler-0.4.3.tar.gz

Download URL librenms_handler-0.4.3.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
37c609ed5928af5030a6bd996c127077dfba49b03afc4e7c43d669de44b3a468
BLAKE2b-256 checksum
How to use checksums
f9a299af6bb60151098b90d9b9baa69266ed9fd840c98b991d2605defd31121c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / librenms_handler-0.4.3-py3-none-any.whl

Download URL librenms_handler-0.4.3-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1db802c6909a7821896c3ae6890c886e9bdca5328e8edb08375c9aa5c5b6fc6
BLAKE2b-256 checksum
How to use checksums
c6c69c9639f8f461bb6933e1f8309fc17bdc1e1e79434783a416729c37ce412c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for librenms-handler 0.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page