scambra / pve-migration-monitor

Daemon to monitor when VM or CT is migrated from or to proxmox VE node
GNU General Public License v3.0
4 stars 2 forks source link

Daemon to monitor when VM or CT is migrated from or to proxmox VE node. Daemon uses inotifywait to monitor changes to conf files in /etc/pve/qemu-server and /etc/pve/lxc directories, which have config files for VM and CT in current node. When VM/CT is migrated out of node, all scripts in down.d directory will be executed, when is migrated into node, all scripts in up.d directory will be executed. Down.d and up.d scripts get config file as argument.

Pve-migration-monitor is a shell script, and it requires inotifywait, curl and jq (provided by inotify-tools, curl and jq debian packages). It also requires grep, awk and sed, which are usually installed in every linux system.

Install script will copy scripts to /etc/pve-migration-monitor and config file to /etc/default/pve-migration-monitor. It will add pve-migration-monitor service to systemd and enable it.

Failover IP

Pve-migration-monitor comes with scripts to change failover IP on VM/CT when is migrated, failoverip-down and failoverip-up (linked to down.d/10failoverip and up.d/10failoverip). Failoverip-up script use another script to change failover IP with API, scripts for Online.net API and Hetzner API are provided.

Install script can be run with -p argument to enable these scripts, and it will ask for online.net api token.

Also, scripts to get public IP on VM/CT are included, they write VM/CT IP to config files in /etc/pve/failoverip by default, so failoverip-down can get failoverip for VM, because qemu/lxc config file has been already removed from node.

To get failover config files, 2 scrips are provided to get them in 2 different ways:

These scripts can be run with -v to print IPs per VM/CT without writting to /etc/pve/failoverip. Only one script is needed, it can be run manually when failover ip is added or removed from VM, or scheduled. Systemd timers are provided to run script hourly, it can be changed to any other frequency.

Acknowledgements

To @biapy for OnlineFailoverIP script, which I based mine on.
To @yennor for proxmox hetzner failover ip scripts, which I used as base for pve-migration-monitor.