Back to Feed
article 2m read

The outage outlasted the UPS, so the wall plugs now vote on mains power

A UPS with no data link let a long city outage kill my main Proxmox host without warning. Smart plugs on wall power, checked against plugs on the UPS, now tell the host when to shut down cleanly and wake itself later.

Article DepthPractice

Flow

Three checks before a shutdown

All three must hold before the host powers off.

  1. 1Controls answer

    Plugs on the UPS still reply, so the radio works.

  2. 2Most wall plugs silent

    More than half, in every room.

  3. 3It lasts

    A few minutes, and not right after a boot.

A city power cut ran my UPS flat, and my main Proxmox host just died. No clean shutdown. Every guest went down with it.

The UPS can't talk to the host. There's no cable for it to say "I'm on battery," so the host had no idea anything was wrong until the power was gone.

So I gave it another way to find out. The smart plugs in my house run on wall power. When the power goes out, they stop answering. The agent wrote a small service on the host that asks those plugs to check in a few times a minute. It talks to them through the VM that runs the Zigbee bridge, using the QEMU guest agent instead of the network. A plug only counts if it sends a fresh reply. An old saved message doesn't count.

The tricky part is not shutting down when the radio is just being flaky. The rules:

  • A couple of plugs sit on the UPS. If those go quiet too, the radio is the problem, not the power, so nothing happens.
  • More than half the wall plugs must be silent, in every room.
  • That has to last a few minutes, and never right after a boot.

When all three hold, the host sets a wake-up alarm for later and shuts down the normal way, so Proxmox stops the guests in order. If the power is back by then, the host starts itself again.

I ran it in watch-only mode first, then turned on real shutdowns the same day after testing the vote. There's an alert if the watcher can't reach the plugs, because then it can't protect anything.

If you build something like this, use control plugs on the UPS, demand a majority across rooms, and watch it before you let it act.

What I haven't seen yet is a real outage with shutdowns on. If the battery dies after the shutdown, I think coming back depends on a BIOS setting this change doesn't touch.

Keep reading

Pick up a connected idea or branch into a nearby one.

3 paths forward