This is a robust telemetry agent designed to be deployed within a testbed environment to monitor and collect power consumption and performance data from both Docker containers and the host system. It actively manages monitoring processes and provides comprehensive access and control via a REST API.
The agent provides a comprehensive monitoring and data collection suite:
- Container Power Monitoring: Actively monitors running Docker containers and initiates per-process ID (PID) power consumption tracking using the PowerJoular utility. Monitoring starts automatically when a new PID appears.
- Host Performance & Power Data: Initiates and manages a background process (using
perf_power_monitor.sh) to collect host system power and performance data using theperfLinux utility. - Dynamic Process Management: Automatically starts PowerJoular for new PIDs and gracefully terminates them when the PID or container disappears.
- RESTful Control & Data Access: Implements a Flask web server on Port 7333 for data retrieval, file download, and full measurement session reset.
This agent is intended to be run directly on the target testbed host.
- Python 3.x
- Docker Engine (installed and running)
- PowerJoular (must be installed on the host system)
perfutility (usually installed via thelinux-toolspackage on the host)sudoaccess for running monitoring tools (PowerJoular andperf_power_monitor.sh)perf_power_monitor.shscript must be available in the same directory or in the system PATH.
- Clone the Repository:
git clone [YOUR_REPO_URL] cd pptam-agent - Install Python Dependencies:
pip install -r requirements.txt
- Run the Agent:
python [YOUR_MAIN_FILE_NAME].py # The default port is 7333
The following parameters are configured within the main agent script:
- Port:
PORT = 7333 - Polling Interval:
REFRESH_INTERVAL_SECONDS = 1(Time between checking Docker containers) - Log Directory:
PID_LOG_DIR = "pid-log"(Directory where all data files and agent logs are stored)
The agent exposes several endpoints for operational control and data retrieval.
| Endpoint | Method | Description |
|---|---|---|
/ or /data |
GET |
Get Status Snapshot. Returns a JSON snapshot of currently monitored containers and their PIDs, including monitoring status (RUNNING, CLOSING, END). |
/files |
GET |
List Files. Returns a list of all data/log filenames currently stored in the pid-log directory. |
/file/<filename> |
GET |
Get Single File Content. Returns the content of a specific file from the pid-log directory. Parameter: Add ?keep=true to prevent deletion after download (default is deletion). |
/download-all |
GET |
Download All Data. Returns a single JSON object containing the content of all files in the pid-log directory and the primary perf_power.csv file. Files are not deleted upon download. |
/reset |
POST/GET |
Reset Measurement. Crucial operational endpoint that performs a full reset: 1) Stops all active PowerJoular processes. 2) Clears all files from the pid-log directory. 3) Clears the in-memory data store. |
All monitoring data is stored in the pid-log directory:
- PID Data: Files named
pid_<container-short-id>_<pid-number>contain PowerJoular data for individual processes. - Host Data: The
perf_power.csvfile (usually generated in the repository root orpid-log) contains the host-level performance data collected by theperfutility.
This project is licensed under the MIT.