This is a service deployed in our local proxmox node that runs daily at 12pm European Central Standard. The purpose of this application is to inform the technical team of Virtual Machines (VMs) that are over 80% storage capacity.
This application uses Python 3.12 and uv, so make sure to install both.
- Python For Linux:
apt install python3For MAC:
brew install python3uvFor Linux and MAC:
curl -LsSf https://astral.sh/uv/install.sh | shThe uv does most of the dependency syncing and installing, therefore all that you need to do is run one command for the whole thing
uv run storage_alarm.pyAfter running this command the libraries will be installed in a virtual environment and the program will run.
This program can run on demand, but it works best as a daily notification on your slack tech channel. Therefore we advise on setting up a crontab
crontab -eAdd your task there like the following (you can copy it)
0 12 * * * cd /path/to/storage_alarm && /path/to/uv run /path/to/storage_alarm/storage_alarm.py >> /path/to/logs/in/storage_alarm/cron.log 2>&1
After correcting the paths to the storage_alarm, uv, and the logs, the crontab will make sure that this application will run daily at noon.
If you pay close attention, the code already includes logging, and after running the project once the log directory will be created automatically. The crontab will leave other errors that would otherwise be silenced in a cron.log file in the same directory as the log files logfile.log.
| Variable | Description |
|---|---|
| PROXMOX_USER | Proxmox user ID |
| PROXMOX_PASSWORD | Corresponding proxmox user password |
| PROXMOX_URL | Proxmox URL |
| PROXMOX_NODES | Nodes present in server/data center |
| PROXMOX_EXCEPTIONS | OPTIONAL: VM ids that should be excluded from the alarm system |
| WEBHOOK_URL | Webhook url for Slack API |
Note
For multiple nodes and exceptions, just add them between parentheses " separated with spaces. The program only looks for spaces.
Because of the kind of data that is retrieved from the proxmox nodes, a QEMU guest agent needs to be enabled in Proxmox. Otherwise, it is not possible, at least for this application, to retrieve the used storage from the VMs.