HoggerLogger is a lightweight system monitoring tool written in Python that aggregates system, process, and GPU metrics. It collects detailed information about CPU, memory, disk, and GPU usage, and aggregates process-level statistics by user. The tool outputs a JSON record at regular intervals, making it easy to integrate with other monitoring systems or log analysis tools.
-
System Usage Monitoring:
Captures overall system metrics such as:- Total processes running
- System memory and CPU usage
- Disk usage for relevant partitions
- Overall GPU usage
-
GPU Monitoring:
Uses thenvsmimodule to scan GPU processes and aggregates GPU utilization and memory usage per user. -
Single Instance Lock:
Uses a Unix socket lock to prevent multiple instances from running simultaneously. -
Configurable Logging Interval:
Allows customization of the log interval (default is 60 seconds). -
JSON Output:
Outputs data in JSON format for easy parsing and integration.
-
Clone the repository:
git clone https://github.com/aesuli/hoggerlogger.git cd hoggerlogger -
Create and activate a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate -
Install the required packages:
pip install -r requirements.txt
Alternatively, install packages individually:
pip install psutil nvsmi
Run the script using Python. The script accepts two optional arguments:
--interval: The logging interval in seconds (default is 60 seconds).--output_file: The file to which output is appended (default is standard output).
python hogger_logger.py --interval 60 --output_file hogger_log.jsonThe script constructs a JSON object with two main sections:
system: Contains overall system metrics.users: Contains aggregated metrics for each user with significant resource usage.
The JSON record is printed (or written to the specified output file) and the script waits for the specified interval before repeating the data collection.
Below is an example of the JSON output produced by the script:
{
"system": {
"time": "2025-02-28T12:00:00",
"total_processes": 150,
"mem_percent": 75,
"cpu_percent": 240,
"gpu_mem_percent": 60,
"gpu_percent": 90,
"disks": [
{
"mount": "/",
"use_percent": 45
},
{
"mount": "/home",
"use_percent": 55
}
]
},
"users": [
{
"user": "alice",
"cpu_percent": 120,
"mem": 2048,
"threads": 150,
"gpu_count": 1,
"gpu_processes": 2,
"gpu_percent": 45,
"gpu_mem": 500,
"open_files": 30
},
{
"user": "bob",
"cpu_percent": 80,
"mem": 1024,
"threads": 100,
"gpu_count": 0,
"gpu_processes": 0,
"gpu_percent": 0,
"gpu_mem": 0,
"open_files": 10
}
]
}This project is licensed under the BSD 3-Clause License.
- Thanks to the developers of psutil and nvsmi for providing the essential tools used in this project.
Happy monitoring!