2.7 KiB
LibreNMS-power-dash
Python code to extract and visualise power data collected from nLogic and APC pdu's via LibreNMS API
Power and Current Data Dashboard
This project consists of two main scripts: one for collecting power and current data from a LibreNMS server and storing it in a SQLite database, and another for visualizing this data using a Plotly Dash dashboard.
Table of Contents
- Prerequisites
- Installation
- Data Collection Script
- Dashboard Script
- Running the Dashboard
- Accessing the Dashboard
Prerequisites
Before you begin, ensure you have the following installed:
- Python 3.11 or later
- SQLite
- LibreNMS server with API access
Installation
Install the required dependencies using pip:
dash plotly pandas sqlite3
You can install these dependencies by running the following command:
pip install dash plotly pandas
Data Collection Script
The data collection script fetches power and current data from a LibreNMS server and stores it in a SQLite database.
Configuration
-
API Configuration:
- Set the API_KEY and LIBRENMS_IP variables in the script to match your LibreNMS server details.
-
Running the Script:
- Run the script using the command: python get_all_by_room.py
Features
- Fetches device IDs and their locations from the LibreNMS server.
- Collects sensor data for current and power.
- Stores the collected data in a SQLite database (power_data.db).
Dashboard Script
The dashboard script visualizes the data stored in the SQLite database using Plotly Dash.
Configuration
-
Database Configuration:
- Ensure the SQLite database (power_data.db) is in the same directory as the script or provide the correct path.
-
Running the Dashboard:
- Run the script using the command: python dash-power.py
Features
- Displays graphs for building totals and individual rooms.
- Allows selection of different time ranges (e.g., last 6 hours, last 1 day, etc.).
- Dynamically updates the legend values based on the zoom level.
- Accessible on external IP addresses.
Running the Dashboard
-
Start the Dashboard:
- Run the script using the command: python dash-power.py
-
Access the Dashboard:
- Open a web browser and navigate to http://127.0.0.1:8050/ to view the dashboard locally.
- To access the dashboard on an external IP, ensure your network settings allow external connections and navigate to http://:8050/.
Accessing the Dashboard
- Local Access: http://127.0.0.1:8050/
- External Access: http://:8050/
Ensure that your firewall and router settings allow incoming connections on port 8050.