Proxmox VM Autoscale is a dynamic scaling service that automatically adjusts virtual machine (VM) resources (CPU cores and RAM) on your Proxmox Virtual Environment (VE) based on real-time metrics and user-defined thresholds. This solution helps ensure efficient resource usage, optimizing performance and resource availability dynamically.
The service supports multiple Proxmox hosts via SSH connections and can be easily installed and managed as a systemd service for seamless automation.
- Overview
- Features
- Prerequisites
- Quick Start
- Usage
- Configuration
- Gotify Notifications
- Development
- Troubleshooting
- Contributing
- Architecture
- Security
- License
Important
To enable scaling of VM resources, make sure NUMA and hotplug features are enabled:
- Enable NUMA: VM > Hardware > Processors > Enable NUMA ☑️
- Enable CPU Hotplug: VM > Options > Hotplug > CPU ☑️
- Enable Memory Hotplug: VM > Options > Hotplug > Memory ☑️
- 🔄 Auto-scaling of VM CPU and RAM based on real-time resource metrics.
- 🛠️ Configuration-driven setup using an easy-to-edit YAML file.
- 🌐 Multi-host support via SSH (compatible with both password and key-based authentication).
- 📲 Gotify Notifications for alerting you whenever scaling actions are performed.
- ⚙️ Systemd Integration for effortless setup, management, and monitoring as a Linux service.
- 🖥️ Proxmox VE 6.0 or higher must be installed on the target hosts
- 🐍 Python 3.6+ installed on the machine running the autoscale service
- 🔑 SSH access to Proxmox hosts (password or key-based authentication)
- 📦 Python packages:
paramiko,PyYAML,requests(installed automatically) - 💻 Basic familiarity with Proxmox
qmcommands and SSH configuration - ⚙️ NUMA and Hotplug features enabled on target VMs (see configuration below)
Contributions are more than welcome! If you encounter a bug or have suggestions for improvement, please open an issue or submit a pull request. See CONTRIBUTING.md for detailed guidelines.
Code improvements by: Specimen67, brianread108
To autoscale LXC containers on Proxmox hosts, check out this related project.
To install Proxmox VM Autoscale, execute the following curl bash command. This command will automatically clone the repository, execute the installation script, and set up the service for you:
bash <(curl -s https://raw.githubusercontent.com/fabriziosalmi/proxmox-vm-autoscale/main/install.sh)🎯 This installation script will:
- Clone the repository into
/usr/local/bin/vm_autoscale - Copy all necessary files to the installation directory
- Install the required Python dependencies from
requirements.txt - Set up a systemd unit file to manage the autoscaling service
Note
The service is enabled but not started automatically at the end of the installation. To start it manually, use the following command.
systemctl start vm_autoscale.serviceImportant
Make sure to review the official Proxmox documentation for the hotplug feature requirements to enable scaling virtual machines on the fly.
To start the autoscaling service:
systemctl start vm_autoscale.serviceTo stop the service:
systemctl stop vm_autoscale.serviceTo view the service status:
systemctl status vm_autoscale.serviceLogs are saved to /var/log/vm_autoscale.log. You can monitor the logs in real-time using:
tail -f /var/log/vm_autoscale.logOr by using journalctl:
journalctl -u vm_autoscale.service -fThe configuration file (config.yaml) is located at /usr/local/bin/vm_autoscale/config.yaml. This file contains settings for scaling thresholds, resource limits, Proxmox hosts, and VM information.
# Thresholds that trigger scaling actions
scaling_thresholds:
cpu:
high: 80 # Scale up when CPU usage exceeds 80%
low: 20 # Scale down when CPU usage falls below 20%
ram:
high: 85 # Scale up when RAM usage exceeds 85%
low: 25 # Scale down when RAM usage falls below 25%
# Resource limits for VMs
scaling_limits:
min_cores: 1 # Minimum CPU cores per VM
max_cores: 8 # Maximum CPU cores per VM
min_ram_mb: 1024 # Minimum RAM in MB (NUMA requires 1024+)
max_ram_mb: 16384 # Maximum RAM in MB
check_interval: 300 # Check VM resources every 300 seconds (5 minutes)
# Proxmox host configuration
proxmox_hosts:
- name: host1
host: 192.168.1.10
ssh_user: root
ssh_password: your_password_here # Or use ssh_key instead
ssh_key: /path/to/ssh_key # Optional: path to SSH private key
ssh_port: 22 # SSH port (default: 22)
# VMs to monitor and autoscale
virtual_machines:
- vm_id: 101
proxmox_host: host1
scaling_enabled: true
cpu_scaling: true # Enable CPU autoscaling
ram_scaling: true # Enable RAM autoscaling
# Logging configuration
logging:
level: INFO
log_file: /var/log/vm_autoscale.log
# Host resource safety limits
host_limits:
max_host_cpu_percent: 90 # Don't scale if host CPU > 90%
max_host_ram_percent: 90 # Don't scale if host RAM > 90%
# Optional: Gotify notifications
gotify:
enabled: false
server_url: https://gotify.example.com
app_token: your_gotify_app_token_here
priority: 5scaling_thresholds: Defines the CPU and RAM usage thresholds that trigger scaling actions (e.g., when CPU > 80%, scale up)scaling_limits: Specifies the minimum and maximum resources (CPU cores and RAM in MB) each VM can havecheck_interval: Time in seconds between resource checks (default: 300 seconds / 5 minutes)proxmox_hosts: Contains details of Proxmox hosts, including SSH credentials and connection settingsvirtual_machines: Lists the VMs to be managed by the autoscaling script, allowing per-VM scaling customizationlogging: Specifies the logging level and log file path for activity tracking and debugginggotify: Configures Gotify notifications to send alerts when scaling actions are performedalerts: Email notification settings (optional) for scaling eventshost_limits: Safety thresholds to prevent scaling when host resources are constrained
Gotify is used to send real-time notifications regarding scaling actions. Configure Gotify in the config.yaml file:
enabled: Set totrueto enable notificationsserver_url: URL of the Gotify server (e.g.,https://gotify.example.com)app_token: Authentication token for accessing Gotify APIpriority: Notification priority level (1-10, where 10 is highest priority)
For a detailed understanding of the system architecture, components, and data flow, see ARCHITECTURE.md.
- Python 3.6 or higher
- Required Python Packages:
paramiko,requests,PyYAML
To install dependencies manually:
pip3 install -r /usr/local/bin/vm_autoscale/requirements.txtTo run the script manually for debugging or testing:
python3 /usr/local/bin/vm_autoscale/autoscale.py- Check logs:
journalctl -u vm_autoscale.service -n 50 - Verify Python installation:
python3 --version(should be 3.6+) - Check configuration: Ensure
/usr/local/bin/vm_autoscale/config.yamlis valid YAML
- Verify SSH credentials: Test manual SSH connection to Proxmox host
- Check SSH port: Ensure
ssh_portin config matches Proxmox host configuration - Key permissions: SSH keys should have permissions 600 (
chmod 600 /path/to/key)
- Check VM is running:
qm status <vm_id>on Proxmox host - Verify hotplug is enabled: Check VM Options > Hotplug settings in Proxmox UI
- Check NUMA: VM > Hardware > Processors > NUMA should be enabled
- Review thresholds: Ensure usage exceeds configured thresholds in
config.yaml - Check cooldown period: Default is 300 seconds between scaling actions
- Verify server URL: Ensure URL is accessible from the machine running the service
- Check app token: Verify token has correct permissions in Gotify
- Review logs: Check for notification errors in
/var/log/vm_autoscale.log
- Check host limits: Service won't scale if host resources exceed
max_host_cpu_percentormax_host_ram_percent - Verify scaling limits: VM may have reached
max_coresormax_ram_mblimits - Check scaling_enabled: Ensure
scaling_enabled: truefor the VM in config
If you encounter issues not covered here:
- Check the GitHub Issues for similar problems
- Review the full logs:
tail -f /var/log/vm_autoscale.log - Open a new issue with:
- Your configuration (sanitized to remove credentials)
- Relevant log excerpts
- Proxmox version and VM configuration
If you like my projects, you may also be interested in these:
- caddy-waf Caddy WAF (Regex Rules, IP and DNS filtering, Rate Limiting, GeoIP, Tor, Anomaly Detection)
- patterns Automated OWASP CRS and Bad Bot Detection for Nginx, Apache, Traefik and HaProxy
- blacklists Hourly updated domains blacklist 🚫
- UglyFeed Retrieve, aggregate, filter, evaluate, rewrite and serve RSS feeds using Large Language Models for fun, research and learning purposes
- proxmox-lxc-autoscale Automatically scale LXC containers resources on Proxmox hosts
- DevGPT Code together, right now! GPT powered code assistant to build projects in minutes
- websites-monitor Websites monitoring via GitHub Actions (expiration, security, performances, privacy, SEO)
- caddy-mib Track and ban client IPs generating repetitive errors on Caddy
- zonecontrol Cloudflare Zones Settings Automation using GitHub Actions
- lws linux (containers) web services
- cf-box cf-box is a set of Python tools to play with API and multiple Cloudflare accounts.
- limits Automated rate limits implementation for web servers
- dnscontrol-actions Automate DNS updates and rollbacks across multiple providers using DNSControl and GitHub Actions
- proxmox-lxc-autoscale-ml Automatically scale the LXC containers resources on Proxmox hosts with AI
- csv-anonymizer CSV fuzzer/anonymizer
- iamnotacoder AI code generation and improvement
Caution
The author assumes no responsibility for any damage or issues that may arise from using this tool.
This project is licensed under the MIT License. See the LICENSE file for complete details.