{"id":24998921,"url":"https://github.com/thiswillbeyourgithub/load_average_balancer","last_synced_at":"2025-07-06T19:37:44.150Z","repository":{"id":270171619,"uuid":"909381722","full_name":"thiswillbeyourgithub/load_average_balancer","owner":"thiswillbeyourgithub","description":"A utility script to delay CPU-intensive tasks until system load average drops below a specified threshold, ideal for managing backups like restic.","archived":false,"fork":false,"pushed_at":"2024-12-29T02:13:29.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T07:52:44.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiswillbeyourgithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-28T14:35:49.000Z","updated_at":"2025-02-01T19:03:31.000Z","dependencies_parsed_at":"2024-12-29T04:55:41.915Z","dependency_job_id":null,"html_url":"https://github.com/thiswillbeyourgithub/load_average_balancer","commit_stats":null,"previous_names":["thiswillbeyourgithub/load_average_balancer.sh","thiswillbeyourgithub/load_average_balancer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fload_average_balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fload_average_balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fload_average_balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fload_average_balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiswillbeyourgithub","download_url":"https://codeload.github.com/thiswillbeyourgithub/load_average_balancer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537034,"owners_count":21120690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T18:52:19.031Z","updated_at":"2025-04-12T07:52:49.227Z","avatar_url":"https://github.com/thiswillbeyourgithub.png","language":"Python","readme":"# Load Average Balancer\n\nA utility script to delay the execution of CPU-intensive tasks (like restic backups) until the system load average drops below a specified threshold.\n\n## Purpose\n\nThis script was created to prevent restic backups from running during periods of high CPU usage. It monitors the system's 15-minute load average and only exits (allowing the backup to proceed) when either:\n- The load average falls below a specified threshold\n- A maximum delay time is reached\n\n## Usage\n\n### Shell Version\n```bash\n./load_average_balancer.sh -d \u003cmax_delay_seconds\u003e -t \u003cload_threshold\u003e\n```\n\n### Python Version\n```bash\npython3 load_average_balancer.py -d \u003cmax_delay_seconds\u003e -t \u003cload_threshold\u003e\n```\n\nThe Python version provides the same functionality as the shell script but uses Python's psutil library for system monitoring. It may be more portable across different operating systems.\n\n### Arguments\n\n- `-d \u003cmax_delay_seconds\u003e`: Maximum time to wait in seconds before allowing the backup to proceed\n- `-t \u003cload_threshold\u003e`: Load average threshold as a fraction of available CPU cores (0-1)\n- `-h`: Display help message\n\n### Example\n\nTo wait up to 1 hour for the load to drop below 80% of available CPU cores:\n\n```bash\n./load_average_balancer.sh -d 3600 -t 0.8\n```\n\n### Integration with restic\n\n#### Shell Version\nAdd this script before your restic backup command:\n\n```bash\n./load_average_balancer.sh -d 3600 -t 0.8 \u0026\u0026 restic backup /path/to/backup\n```\n\n#### Python Version\n```bash\npython3 load_average_balancer.py -d 3600 -t 0.8 \u0026\u0026 restic backup /path/to/backup\n```\n\n## Requirements\n\n### Shell Version\n- zsh shell\n- bc (basic calculator)\n- Standard Unix utilities (uptime, nproc)\n\n### Python Version\n- Python 3.6 or higher\n- psutil package (install with `pip install psutil`)\n- Compatible with Linux, macOS, and other Unix-like systems\n\n## Exit Codes\n\n- 0: Success (either load dropped below threshold or maximum delay was reached)\n- 1: Invalid arguments or usage error\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Fload_average_balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiswillbeyourgithub%2Fload_average_balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Fload_average_balancer/lists"}