Skip to content

Repository files navigation

Storage alarm

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.

Requisites

This application uses Python 3.12 and uv, so make sure to install both.

  1. Python For Linux:
apt install python3

For MAC:

brew install python3
  1. uv For Linux and MAC:
curl -LsSf https://astral.sh/uv/install.sh | sh

Running the project

The 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.py

After running this command the libraries will be installed in a virtual environment and the program will run.

Setting a crontab and logging

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 -e

Add 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.

Environment variables

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.

Known issues

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.

About

Project to keep track of storage of students storage machines.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages