PVE-UPS: A Proxmox SNMP UPS Shutdown Service

A number of years ago I transitioned from a cheap UPS for my home lab that only supported USB shutdown to a rack mount APC UPS that supported SNMP via a network card. However, I never found web friendly interface to gracefully shut down my Proxmox hosts. However, that has now changed!

A new project has popped up on GitHub called PVE-UPS. PVE-UPS is a small service running in a LXC that monitors network UPS devices via SNMP and can gracefully shutdown one or more Proxmox hosts. I had it up and running in just a few minutes. Just to be clear, if your UPS only supports a USB interface, PVE-UPS is not for you. Use something like NUT for your USB-only UPS. 

PVE-UPS has a pretty simple architecture:

  • The installer script will create a LXC and perform all of the needed installation steps. The LXC is unprivileged, and is allocated 256MB of RAM. Actual use is about 100MB. 
  • The configuration is entirely web based, so no need to edit any text files.
  • It uses the Proxmox API (and token) to communicate with Proxmox hosts to send shutdown commands. A local account is created which only has the “Sys.PowerMgmt” privilege. 
  • It supports SNMP v1/v2c/v3. 

PVE-UPS features include:

  • Supports multiple UPS devices and multiple Proxmox hosts. Has and/or logic to support redundancy or split loads.
  • Variety of shutdown triggers: Charge level, runtime remaining, time on battery, or UPS reporting low battery. 
  • Configuration import/export.
  • Visual event log history with ability to clear all events.

PVE-UPS has a robust safety model:

  • A dropped SNMP connection will not cause a shutdown.
  • After the installation it defaults to dry-run mode. You can arm it after everything checks out.
  • If you have multiple Proxmox hosts, the host running the LXC is shutdown last.

Installation

The PVE-UPS Github page has the full installation instructions, which are well written and easy to follow so I won’t duplicate them here. The installation process at a high level is:

  • Run the installer script in the Proxmox VE shell, which creates the LXC container and performs all of the needed software installation steps.
  • Open the web interface and configure your UPS device(s).
  • Create a local least-privileged Proxmox account to be used by PVE-UPS for shutdown commands.
  • Add your Proxmox host(s) and configure the shutdown triggers and logic.

UPS and Proxmox Configuration

Configuring a UPS device is very to do. First, go to your UPS network management interface and configure your SNMP settings including version and any security settings. Note: There appears to be a bug that won’t allow any Auth or Priv settings due to crypto issues. But it works fine with no security. Obviously not ideal. I opened a Github issue. But this is a home lab, so I’m not too worried about it. The Test button is very handy and a great touch. 

Adding a Proxmox host is just as easy as adding a UPS device. During the installation the guide has you create a local Proxmox user with an API token. Input that information, hostname and URL. If needed, adjust the trigger settings.

Time for Testing

PVE-UPS is very responsive and within a few seconds of a power outage it registered that the UPS was on battery. The dashboard updates in real time and keeps you apprised of the shutdown status. 

Summary

Brand new to the community is the PVE-UPS service for Proxmox VE. It’s a lightweight LXC container that supports SNMP-based UPSes (no USB UPS support). It supports multiple UPSes, multiple Proxmox hosts, and is very configurable. The installation and configuration is very simple and straightforward. Although the version I tried didn’t work with SNMP encryption, it wasn’t a big deal for my home network. Hopefully the developer will fix this bug. Other than that bug it works great. If you have any Proxmox hosts and a SNMP-based UPS give it a try. 

Related Posts

Leave a Comment

Your email address will not be published. Required fields are marked *