Package: librenms-handler
LibreNMS handlerA 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 thereference guidethemselves.I have not used it myself so I cannot endorse it, but a quick search shows thatLibreNMSAPIhas a similar goal with a different outlook.
Consider checking it out if this project doesn't suit your needs!UsageThe package is installed with the following package managers like so:Pippip install librenms-handlerPipenvpipenv install librenms-handlerThe following statement will initialise the chosen endpoint:fromlibrenms_handler.devicesimportDevicesdevices=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 optionverify=False.Once done, a list of methods will be available to you such asdevices.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 EndpointEnvironment variablesWhile initialising the handler, the following parameters are required.
The handler first checks for the following environment variables, should you choose to use them.Environment variableDescriptionTypeExampleLIBRENMS_URLFull URL to the target LibreNMS instancestringhttps://librenms.example.comLIBRENMS_TOKENToken generated fromLIBRENMS_URL/api-accessstringe4ef9234abab59a90628dd3f616a60b4EndpointsThe progress of API endpoints are shown in their respective projects below:
SeeProjectsto 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.EndpointStartedAlertsFalseARPTrueBillsFalseDevice GroupsTrueDevicesTrueInventoryTrueLocationsTrueLogsTruePort GroupsFalsePortsFalseRoutingFalseServicesFalseSwitchingTrueSystemTrue