README update

This commit is contained in:
Radek
2025-05-21 15:19:03 +01:00
parent 4759f6c177
commit 9cffa4c8e4

View File

@@ -1,3 +1,90 @@
# 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](#prerequisites)
- [Installation](#installation)
- [Data Collection Script](#data-collection-script)
- [Dashboard Script](#dashboard-script)
- [Running the Dashboard](#running-the-dashboard)
- [Accessing 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
1. API Configuration:
- Set the API_KEY and LIBRENMS_IP variables in the script to match your LibreNMS server details.
2. 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
1. Database Configuration:
- Ensure the SQLite database (power_data.db) is in the same directory as the script or provide the correct path.
2. 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
1. Start the Dashboard:
- Run the script using the command: python dash-power.py
2. 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://<your-external-ip>:8050/.
## Accessing the Dashboard
- Local Access: http://127.0.0.1:8050/
- External Access: http://<your-external-ip>:8050/
Ensure that your firewall and router settings allow incoming connections on port 8050.