idlesleep/README.md

53 lines
1.3 KiB
Markdown

# Idle Sleep Monitor
This program monitors system resource usage and automatically suspends the system when it detects extended periods of low resource utilization.
## Requirements
- Linux system with systemd
- NVIDIA GPU with drivers installed
- Go 1.21 or later
- Root privileges (required for system suspension)
## Installation
1. Clone this repository
2. Install dependencies:
```bash
go mod download
```
3. Build the program:
```bash
go build
```
## Usage
The program must be run as root since it needs permissions to suspend the system:
```bash
sudo ./idlesleep
```
The program will monitor the following metrics over a 5-minute period:
- CPU usage across all cores (threshold: < 20%)
- GPU usage (threshold: < 20%)
- Disk I/O (threshold: < 5 MB/s)
- Network I/O (threshold: < 1 MB/s)
If all metrics stay below their thresholds for the entire monitoring period, the system will be suspended.
## Configuration
The thresholds are defined as constants in `main.go`. You can modify them by editing the following values:
```go
const (
checkInterval = 10 * time.Second
monitoringPeriod = 5 * time.Minute
cpuThreshold = 20.0 // percentage
gpuThreshold = 20.0 // percentage
diskThreshold = 5 * 1024 * 1024 // 5 MB/s
networkThreshold = 1 * 1024 * 1024 // 1 MB/s
)
```