Configuration of an APC UPS under Proxmox
This is how to configure an APC-UPS under Proxmox:
These instructions are based on (German Text): https://www.maffert.net/proxmox-debian-usv-ups-von-apc-installieren-und-konfigurieren/
0. Connect the UPS to the server and switch it on
- The UPS can be controlled with the software apcupsd. Installation of this program:
apt-get install apcupsd
2. Editing the configuration file:
nano /etc/apcupsd/apcupsd.conf
The following options have to be changed in this file:
UPSNAME *Enter any device name*
UPSCABLE usb
UPSTYPE usb
DEVICE *leave empty, the program will automatically detect the UPS*
NETSERVER on
NISIP 0.0.0.0
Furthermore, in this file the following settings can be changed:
- ONBATTERYDELAY
- The time between power failure and triggering of the „ON BATTERY“ event in seconds. The standard is 6 seconds so that an action is not triggered directly in the event of a brief failure.
- BATTERYLEVEL
- This is the limit in percent of remaining battery capacity from when the server will shut down.
- MINUTES
- If the remaining runtime (calculated by the UPS) is less than this value (in minutes), the server is shut down.
- EVENTSFILE
- The path to the log file
- POLLTIME
- Time in seconds how often the server queries the UPS for its status
3. „Tell“ the program that it is completely configured:
put in the file:
nano /etc/default/apcupsd
ISCONFIGURED=yes
4. Start the program and check function:
apcupsd start
apcaccess status
5. Optional: Install web interface:
apt-get install apcupsd-cgi apache2
a2enmod cgi
systemctl restart apache2
Call up the status page at:
http://---SERVER_IP---/cgi-bin/apcupsd/multimon.cgi
Configuration of Slaves
If other servers are connected to the UPS, they can be configured in such a way that the MASTER server (which is connected to the UPS via USB) causes the SLAVES to shut down in the event of a power failure.
These steps can also be carried out in Proxmox VMs, which cannot be shut down via the Proxmox interface.
See also: https://www.pontikis.net/blog/apc-ups-master-slave-setup-apcupsd
- Changes in the configuration of the master:
nano /etc/apcupsd/hosts.conf
Enter the IP addresses of the servers that should work as SLAVES (these should be static IPs!):
# MONITOR <address> "<host description>"
MONITOR 192.168.1.52 "Backup server"
MONITOR 192.168.1.51 "Server 2"
systemctl restart apcupsd.service
2. Configuration of the SLAVE computers:
apt-get install apcupsd
nano /etc/apcupsd/apcupsd.conf
Change in this file:
UPSCABLE ether
UPSTYPE net
POLLTIME 10
# IP of the MASTER COMPUTER (in my case 192.168.1.52), The standard port for apcupsd is 3551
DEVICE 192.168.1.52:3551
The rest of the configuration is as above.
Optional: Web interface for quick access to the UPS status pages
I have created a small web interface that enables quick access to the status page and the Proxmox web interface.
To use it, just execute the following commands:
- Create a file „index.html“ in the web server directory
nano /var/www/html/index.html
2. Paste the following content into this file. The IP address to the Proxmox web interface has to be replaced by the IP address of the respective Proxmox server:
<title>Proxmox-USV</title>
<body>
<h3>USV Status</h3> <br>
<a href="/cgi-bin/apcupsd/multimon.cgi">
apcupsd MultiMon
</a><br>
<a href="/cgi-bin/apcupsd/upsstats.cgi">
apcupsd Stats
</a><br>
<a href="/cgi-bin/apcupsd/upsfstats.cgi">
apcupsd fStats
</a><br><br><br>
<h3>Proxmox Webinterface</h3><br>
<a href="https://192.168.1.12:8006"> <!-- enter IP here! -->
Proxmox Webinterface
</a>
</body>
After that save the file. Now the interface can simply be called up under the server IP (http://–SERVER-IP–).
6 Kommentare
Robert · 9. April 2023 um 22:28
Just what I was looking for! Thanks. I use your simple web interface now. Very useful.
Taomyn · 13. Dezember 2023 um 16:12
Is there an updated version for this because Proxmox no longer uses apache2 and instead has pveproxy to publish the web interface. Not sure that installing apache2 would be a good idea.
brun · 19. Dezember 2023 um 21:13
I have not yet looked into that since I am not running the latest version of proxmox on this system.
loulou91 · 20. Dezember 2023 um 17:16
Thank you for the tip!
And now, how could I simply check ups status and battery level in order tu request a stopall (containers and VMs)?
Any idea?
brun · 22. Dezember 2023 um 18:50
All this is done by the software apcupsd. If the UPS signals a power outtage, the proxmox-host is automatically shut down (after the configured interval). Before the proxmox-host shuts itself down, all VMs and containers are automatically shut down to.
Uwe · 2. Juli 2024 um 7:07
I have installed the webinterface. The Link „apcupsd MultiMon“ works fine but the other two links only show this error: „Access to host 127.0.0.1 is not authorized.“
Any hint how I can resolve this?
Thanks and regards