diff --git a/README.md b/README.md index 6917d07..6d2e66a 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +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://: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.