Skip to main content

A plugin for NetBox to easily display PDU information.

Project description

Netbox PDU Plugin

A plugin for Netbox to get power distribution unit Information.

axians-netbox-plugin-pdu is using Easy SNMP, Django-RQ and RQ-Scheduler to display PDU information within Netbox.

Installation

The plugin is available as a Python package in pypi and can be installed with pip

pip install axians-netbox-plugin-pdu

The plugin is compatible with NetBox 2.9.1 and higher

Once installed, the plugin needs to be enabled in your configuration.py

PLUGINS = ["axians_netbox_pdu"]

# PLUGINS_CONFIG = {
#   "axians_netbox_pdu": {
#     ADD YOUR SETTINGS HERE
#   }
# }

There are a number of default settings that can be altered using the following list of settings:

  • schedule: Boolean (default True). If True, this will enable automatic polling of your PDU Devices.
  • schedule_interval: Integer (default 300 seconds). Length of time between each scheduled poll.
  • snmp_read: String (default public) SNMP read value for your SNMP enabled PDU's.
  • snmp_write: String (default private) SNMP write value for your SNMP enabled PDU's.
  • rack_view_pdu_devices: Boolean (default True), if True, the power usage per PDU will be displayed on the rack page.
  • rack_view_usage_summary: Boolean (default True), if True, the a summary information tile will appear within the rack page to show true power utilization within the rack.
  • rack_view_summary_unit: String (default watts), option to display watts/kilowatts on the rack summary view. If "kilowatts" is used the power usage summary will display in Kilowatts.

Usage

Preparation

For this plugin to work there must be a new worker added to your Netbox installation. The new worker is a custom scheduler that will schedule the PDU Tasks to run on an interval and utilize the django-rq library.

You can utilize this library without the automated tasks by feeding Netbox the power usage information via the axians_netbox_pdu API.

Default Environment

For the standard install please use the included netbox-pdu.service and install using the standard Netbox Documentation.

Docker Environment

To use within Docker make sure you have a container running that runs the following command: python manage.py pduschedule

Adding a new PDU Configuration

Once installed and the pduscheduler is running you can attach a PDUConfig to a DeviceType. To do this you must have a DeviceType configured with PowerOutlets. You can specify the DeviceType, PDU SNMP OID and the Unit. This enables the plugin to know what SNMP OID to collect per DeviceType.

Now a PDUConfig has been created a device must be created with a management IP. Once this is done the plugin can poll the PDU via SNMP and save the power usage.

This can also be done via Bulk Import or via the API.

If a a PDUConfig is not created for a DeviceType and the Device does not have a Primary IP no data will be collected.

API

The plugin includes several endpoints to manage the PDUConfig and PDUStatus.

GET       /api/plugins/pdu/pdu-config/         List PDUConfig
POST      /api/plugins/pdu/pdu-config/         Create PDUConfig
PATCH/PUT /api/plugins/pdu/pdu-config/{id}/    Edit a specific PDUConfig
DELETE /api/plugins/pdu/pdu-config/{id}/       Delete a specific PDUConfig

GET       /api/plugins/pdu/pdu-status/         List PDUStatus
POST      /api/plugins/pdu/pdu-status/         Create PDUStatus
PATCH/PUT /api/plugins/pdu/pdu-status/{id}/    Edit a specific PDUStatus
DELETE /api/plugins/pdu/pdu-status/{id}/       Delete a specific PDUStatus

Screen Shots

List of PDUConfig Instances PDUConfig List View

Import PDUConfig Instances PDUConfig Import View

Edit PDUConfig Instances PDUConfig Edit View

View PDUStatus Device View PDUStatus Device View

View PDUStatus Rack View PDUStatus Rack View

Contributing

Pull requests are welcomed.

The project is packaged with a light development environment based on docker-compose to help with the local development of the project.

  • Black, Pylint, Bandit and pydockstyle for Python linting and formatting.
  • Django unit test to ensure the plugin is working properly.

CLI Helper Commands

The project comes with a CLI helper based on invoke to help setup the development environment. The commands are listed below in 3 categories dev environment, utility and testing.

Each command can be executed with invoke <command>. All commands support the arguments --netbox-ver and --python-ver if you want to manually define the version of Python and Netbox to use. Each command also has its own help invoke <command> --help.

Local dev environment

  build            Build all docker images.
  debug            Start NetBox and its dependencies in debug mode.
  destroy          Destroy all containers and volumes.
  start            Start NetBox and its dependencies in detached mode.
  stop             Stop NetBox and its dependencies.

Utility

  cli              Launch a bash shell inside the running NetBox container.
  create-user      Create a new user in django (default: admin), will prompt for password.
  makemigrations   Run Make Migration in Django.
  nbshell          Launch a nbshell session.

Testing

  tests            Run all tests for this plugin.
  pylint           Run pylint code analysis.
  pydocstyle       Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
  bandit           Run bandit to validate basic static code security analysis.
  black            Run black to check that Python files adhere to its style standards.
  unittest         Run Django unit tests for the plugin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axians-netbox-plugin-pdu-0.0.3.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

axians_netbox_plugin_pdu-0.0.3-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file axians-netbox-plugin-pdu-0.0.3.tar.gz.

File metadata

  • Download URL: axians-netbox-plugin-pdu-0.0.3.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.6.9 Linux/4.15.0-112-generic

File hashes

Hashes for axians-netbox-plugin-pdu-0.0.3.tar.gz
Algorithm Hash digest
SHA256 63dc38349daee03b33f75cea8e91920af1f9c9de940eca96f48d39dcb394c74d
MD5 57c39f1819302eb7abfa4e9bf8a4c3f3
BLAKE2b-256 a3bc0b1db10b9e62a54249bf067f34567207b8701d4dc807e95744dd43fc2a47

See more details on using hashes here.

File details

Details for the file axians_netbox_plugin_pdu-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for axians_netbox_plugin_pdu-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a147af7466914f41ef876156562749050570372172ece5c1099b834cc4448bb9
MD5 47b0a3e5ebed3bda695db6ce09be584d
BLAKE2b-256 61ae12586df5cc6745e661ac352a7008d3778864f6384a587142a5863c2e32a0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page