Installation APC Dienste
apt install apcupsd
Konfiguration Master Server (bei dem die USV via USB Kabel verbunden ist)
nano /etc/apcupsd/apcupsd.conf UPSCABLE usb UPSTYPE usb NETSERVER on NISIP 0.0.0.0
Konfiguration Slave Server
nano /etc/apcupsd/apcupsd.conf UPSCABLE ether UPSTYPE net DEVICE 10.2.51.1:3551 //IP vom Master Server
Dienste installieren und starten
service apcupsd start apt install apcupsd-cgi apt install apache2 a2enmod cgi systemctl restart apache2
VMs herunterfahren
Skript zur kontrollierten Abschaltung von virtuellen Maschinen in Proxmox, wenn ein Stromausfall erkannt wird.
HA wird zuvor bei den VMs deaktiviert um ein automatisches Neustarten zu verhindern.
/etc/apcupsd/shutdownvms.sh
#!/bin/bash
# Create list of VM Ids
running_vms=$(qm list | awk '/running/ {print $1}')
# Shutdown each VM
for vmid in $running_vms; do
echo $(date +"%Y-%m-%d_%H-%M-%S ")"Disable HA For VM: "$vmid >> /var/log/shutdownvm.log
ha-manager set $vmid --state ignored
echo $(date +"%Y-%m-%d_%H-%M-%S ")"Shutdown VM: "$vmid >> /var/log/shutdownvm.log
qm shutdown $vmid --skiplock
sleep 2
done
Einstellung in /etc/apcupsd/apccontrol
doshutdown)
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
/etc/apcupsd/shutdownvms.sh
${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
;;
Shutdown-Zeit einstellen
/etc/apcupsd/apcupsd.conf