I have an APC-made UPS (uninterruptable power supply). It comes with the ability for connected PCs to monitor its state.
I have it connected by USB cable to the desktop machine. That machine communicates with the server, so they are both aware of power status.
Simply follow the Ubuntu instructions.
The desktop machine has
UPSCABLE usb UPSTYPE usb DEVICE POLLTIME 60
The server machine has
UPSCABLE ether UPSTYPE net DEVICE desktop.domain.tld:3551 POLLTIME 10
The desktop machine will require port 3551 open on its firewall.
On both machines, set
/etc/default/apcupsd and restart the monitor.
root@server:~# systemctl restart apcupsd.service root@server:~# apcaccess status
Finally, configure the BIOS on all machines to start automatically when power is supplied.