# Power Monitoring System ## Overview The Power Monitoring System is designed to collect, store, and visualize power usage data from various devices, primarily PDUs (Power Distribution Units). The system consists of two main components: a data collection script and a dashboard for visualizing the collected data. ## Data Collection Script ### Purpose The data collection script is responsible for fetching power usage data from devices via an API, processing this data, and storing it in a SQLite database. The script is designed to run at regular intervals to ensure up-to-date data collection. ### Features - **Concurrent API Requests**: The script uses concurrent requests to efficiently gather data from multiple devices simultaneously, reducing the overall execution time. - **Data Rounding**: Timestamps for the collected data are rounded to the nearest 5-minute interval to ensure consistency and alignment with the dashboard's requirements. - **Configurable Concurrency**: The concurrency level can be adjusted to balance between speed and system load, ensuring optimal performance without overloading the API server. - **Database Storage**: Collected data is stored in a SQLite database, with separate tables for building totals, room breakdowns, and customer breakdowns. ### Usage 1. **Configuration**: Ensure that the API key, LibreNMS IP, and other necessary configurations are set in the script. 2. **Running the Script**: Execute the script with the desired options, such as enabling debug output, limiting the number of runs, disabling database updates, and setting the concurrency level. 3. **Scheduling**: Schedule the script to run at regular intervals (e.g., every 5 minutes) using a task scheduler like `cron` or the Task Scheduler. ### Command Line Options - `--debug`: Enable debug output for troubleshooting. - `--runs`: Limit the number of runs for testing purposes. - `--no-db-update`: Disable updates to the database to run the script in a read-only mode. - `--concurrency-level`: Set the concurrency level for API requests to optimize performance. ## Dashboard ### Purpose The dashboard provides a visual representation of the power usage data collected by the script. It allows users to monitor power consumption, identify trends, and make informed decisions based on the data. ### Features - **Data Visualization**: The dashboard displays power usage data in an easy-to-understand format, with charts and graphs for building totals, room breakdowns, and customer breakdowns. - **Regular Updates**: The dashboard is updated at regular intervals to reflect the latest data collected by the script. - **User-Friendly Interface**: The dashboard is designed to be intuitive and user-friendly, allowing users to quickly access the information they need. ### Usage 1. **Accessing the Dashboard**: Open the dashboard in a web browser to view the power usage data. 2. **Interpreting the Data**: Use the charts and graphs to monitor power consumption and identify any trends or anomalies. 3. **Customization**: Customize the dashboard as needed to display the most relevant information for your use case. ## System Requirements - **Python**: The data collection script is written in Python and requires a Python environment to run. - **SQLite**: The script uses SQLite for data storage, so SQLite must be installed and accessible. - **LibreNMS API**: The script interacts with the LibreNMS API to fetch power usage data, so access to this API is required. ## Conclusion The Power Monitoring System provides a comprehensive solution for collecting and visualizing power usage data. By using the data collection script and dashboard together, users can efficiently monitor power consumption and make data-driven decisions.