$ show fabriziosalmi/proxmox-vm-autoscale
This repository implements a threshold-based vertical autoscaling system for Proxmox VE virtual machines. It runs as a systemd service that periodically polls VM CPU and RAM usage via SSH commands (qm, pvesh) and adjusts CPU cores and RAM by 1 core or 512 MB when configurable high/low thresholds are crossed. The system includes host resource safety limits, per-VM threshold overrides, independent cooldowns for CPU and RAM, and optional billing tracking with CSV export and webhook notifications. It also provides a lightweight Prometheus metrics endpoint built on stdlib, supports Gotify and SMTP notifications, and offers a dry-run mode for safe evaluation. The architecture is a single-threaded polling loop with in-memory state, designed for simplicity and reliability rather than horizontal scaling or predictive analytics. The codebase is well-tested with over 290 unit tests and end-to-end tests against real Proxmox nodes, and includes comprehensive documentation via a VitePress site. Key reusable components include a generic SSH client with retry/backoff and host key policies, a thread-safe Prometheus metrics registry without external dependencies, and a configuration validation module that reports all errors at once.
The LLM identified 4 files worth highlighting for reuse:
A generic Paramiko-based SSH client wrapper with configurable host key verification policies (accept-new, strict, auto), exponential backoff retry logic, and context manager support. It is self-contained, requires only paramiko, and can be extracted for any SSH automation task beyond Proxmox.
A lightweight Prometheus metrics registry and HTTP exposition server built entirely on Python stdlib (http.server, threading). Provides thread-safe counter and gauge registration, and serves /metrics on a configurable localhost port. Reusable for any application needing basic monitoring without external dependencies.
A comprehensive YAML configuration validator that checks types, ranges, and referential integrity in a single pass, reporting all errors at once (including unknown keys as warnings). It is decoupled from the rest of the application and can be adapted for validating any nested configuration structure.
A test helper module that constructs real application objects (VMAutoscaler, SSHClient, etc.) with sensible defaults, enabling integration-style tests without mocking. Demonstrates a pattern for building complex test fixtures that reduce test fragility and improve coverage realism.