idlesleep/README.md

1.3 KiB

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:
go mod download
  1. Build the program:
go build

Usage

The program must be run as root since it needs permissions to suspend the system:

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:

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
)