UPS shutdown with NUT over SNMP – Part 1: Proxmox VE

My Proxmox host and my TrueNAS share one UPS: an APC Smart-UPS SMT1500RMI2U with an AP9630 (NMC2) network management card. No USB cable, just Ethernet/SNMP.

Until now NUT ran as a container on the Proxmox host and served everything else. That’s a classic single point of failure: if Proxmox goes down first, the NUT server goes with it and nobody else gets told anything.

The design

  • No master/slave. Each host polls the UPS card itself over SNMP and shuts itself down.
  • Staggered thresholds: Proxmox shuts down at 50% battery, TrueNAS only at 40%. That way every VM/container writing to NAS shares is already stopped cleanly before the NAS goes down (consumer before provider).
  • Read-only SNMP community. No host can accidentally cut power to the shared UPS, even though NUT runs locally as primary.

Part 2 covers the TrueNAS side. This part is about Proxmox VE 8 (Debian 12, NUT 2.8.0).

1. Enable SNMP on the AP9630

Out of the box the card doesn’t answer SNMPv1 queries. In the card’s web interface:

  • Configuration → Network → SNMPv1 → Access: tick “Enable SNMPv1 access”
  • Configuration → Network → SNMPv1 → Access Control: community public with access type Read. Set the NMS IP to 0.0.0.0 (any host) or, better, restrict it to your own hosts.

SNMPv1 is unencrypted. That’s acceptable on a trusted management VLAN; if you want it cleaner, use SNMPv3, which NUT supports too.

Before anything else, check that the host can actually reach the card (in these examples the card is at 192.168.1.50):

If it returns the model (e.g. “Smart-UPS SMT1500…”), you’re good. A timeout almost always means a wrong IP, a routing/VLAN issue, or SNMPv1 not yet enabled on the card.

2. Install NUT

Debian splits NUT into several packages. The SNMP driver lives in its own package, which is easy to miss:

3. Configuration

Four files under /etc/nut/.

/etc/nut/nut.conf: the host only looks after itself:

/etc/nut/ups.conf:

  • For snmp-ups, port is the card’s IP, not a device path.
  • mibs = apcc is right for the AP9630. auto usually works too; if the driver won’t bind, set apcc explicitly.
  • override.battery.charge.low = 50 together with ignorelb makes NUT raise low-battery itself at 50% instead of waiting for the UPS’s own (much later) low-battery flag. This is where you set the host’s threshold.

Note: with ignorelb, NUT triggers on either battery.charge ≤ 50 or the UPS’s battery.runtime.low. At light load the percentage threshold trips first.

/etc/nut/upsd.users:

/etc/nut/upsmon.conf: the file ships with lots of commented examples; these two lines are what matters:

The password must match in both files. There’s deliberately no power-off command for the UPS: it’s still powering the TrueNAS. With a read-only community it wouldn’t work anyway.

4. Start and verify

If the driver doesn’t come up the first time (Debian generates the driver units from ups.conf), this helps:

Then check:

The log should show a line like UPS: smt1500@localhost (primary) (power value 1) with no “Login failed” after it:

5. Optional: notifications to Mattermost

NUT can run a script on every event. I send them to a Mattermost channel through an incoming webhook, with a colored bar by severity. (Create the webhook under Integrations → Incoming Webhooks. The URL works like a password, so keep it secret.)

/etc/nut/notify.sh:

Then wire it up in /etc/nut/upsmon.conf. The EXEC flag is the important part; without it upsmon logs the event but never runs the script:

Test without a power cut, first just the webhook:

Then the full path through upsmon: stop nut-server for about 20 seconds and start it again. You should get a COMMBAD and then a COMMOK in the channel. This is safe as long as the UPS is on line power (OL): losing comms only forces a shutdown if the UPS was last seen on battery.

Mattermost channel showing three NUT alerts from the Proxmox host: a manual ONBATT test, COMMBAD (comms lost) and COMMOK (comms restored)
The test in practice: manual ONBATT test, then COMMBAD and COMMOK from stopping and starting nut-server.

Pitfalls

  • Forgetting nut-snmp: without that package there is no snmp-ups driver.
  • SNMPv1 not enabled on the card: the most common cause of timeouts.
  • No COMMOK after a restart: on a clean first connection upsmon stays quiet. COMMOK only fires after a previous loss of comms.
  • Short network blips over SNMP tend to produce a COMMBAD/COMMOK pair. If that gets noisy, drop those two flags and only report the power events.
  • Guest shutdown timeouts: Proxmox stops all VMs/containers while shutting down. Their combined timeouts have to fit in the window between 50% and 40%, or the NAS is gone before the last VM is done.
  • BIOS: enable “power on after AC loss”, or the servers stay off when the power comes back.

Finally: actually test it

A config that looks right and one that shuts the host down cleanly at the right moment are two different things. In a maintenance window, pull the UPS’s mains plug (or simulate a power failure from the card) and watch: OL → OB → OB LB, Proxmox goes down at 50%, TrueNAS follows at 40%.

Continue with Part 2: TrueNAS SCALE.

Leave a comment