Network UPS Tools (NUT) is a client/server
monitoring system that allows computers to share uninterruptible power supply
(ups) and power distribution unit (PDU) hardware. Clients
access the hardware through the server, and are notified whenever the power
status changes.

In the following scenario, the server acts as the master. He monitors and
controls the UPS via USB data cable and keeps the slaves updated about the
current situation.

The router and the NAS act as slaves. They
get status updates about the UPS battery state and power supply from the
master.

If the master gets notified by the UPS that its battery is getting close to
depletion, he will instruct the slaves to shutdown.

The master will start its own shutdown procedure and instruct the UPS to cut
the power, after he has confirmation from all the slaves, that they are
shutting down.

The Wi-Fi AP has no Network UPS Tools installed, thus
he is not aware of the current situation. He will however be shut down by the
master via remote SSH command, in case the battery is low during a power
outage.

The Ethernet switch, has also no knowledge about the UPS. He will shut down
uncontrolled, when the UPS battery is depleted or when the UPS is ordered to
cut the power by the master.

# IMPORTANT NOTE:# This file is intended to be sourced by shell scripts. You MUST NOT use# spaces around the equal sign!## Required. Recognized values are none, standalone, netserver and netclient.# Defaults to none.MODE=netserver

This file is read by the driver controller. It tells the Network UPS Tools
what kind of UPS device it has to work with. Some settings to control
communications with the device. Also some of the UPS device parameters can be
overridden.

## upsd.conf - Configuration for Network UPS Tools upsd## Interfaces to listen for TCP connections from clients.# if not specified, the default port is 3493.# This will only be read at startup of upsd. If you make changes here,# you'll need to restart upsd, reload will have no effect.#LISTEN 127.0.0.1LISTEN ::1LISTEN 192.0.2.10LISTEN 2001:db8:c0de::10

Administrative commands such as setting variables and the instant commands are
powerful, and access to them needs to be restricted. This file defines who may
access them, and what is available.

Each user gets its own section. The fields in that section set the parameters
associated with that user’s privileges. The section begins with the name of
the user in brackets, and continues until the next user name in brackets or
EOF. These users are independent of /etc/passwd.

## upsmon.conf - Configuration for Network UPS Tools upsmon## Drop privileges to the following user profile after startup.RUN_AS_USER nut# List of UPS devices to monitor.MONITOR apc@localhost 1 upsmon ******* master# Number of power supplies receiving power to keep this system running.MINSUPPLIES 1# Command to run when to shutdown this system.SHUTDOWNCMD "/bin/systemctl halt"# Command to run on +EXEC events.NOTIFYCMD "/sbin/upssched"# Change behavior of upsmon on certain events.## Possible values for the flags:## SYSLOG - Write the message in the syslog# WALL - Write the message to all users on the system# EXEC - Execute NOTIFYCMD (see above) with the message# IGNORE - Don't do anything## If you use IGNORE, don't use any other flags on the same line.## NOTIFYFLAG <notify type> <flag>[+<flag>][+<flag>] ...#NOTIFYFLAG ONLINE SYSLOG+WALL+EXECNOTIFYFLAG ONBATT SYSLOG+WALL+EXECNOTIFYFLAG LOWBATT SYSLOG+WALL+EXECNOTIFYFLAG FSD SYSLOG+WALL+EXECNOTIFYFLAG COMMOK SYSLOG+WALL+EXECNOTIFYFLAG COMMBAD SYSLOG+WALL+EXECNOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXECNOTIFYFLAG REPLBATT SYSLOG+WALL+EXECNOTIFYFLAG NOCOMM SYSLOG+WALL+EXECNOTIFYFLAG NOPARENT SYSLOG+WALL# Poll the UPS every 5 seconds.POLLFREQ 5# If the UPS is on battery, poll it every 5 seconds.POLLFREQALERT 5# Wait no more then 15 seconds for "Notify Shutdown" messages from slaves.HOSTSYNC 15# Wait no more then 15 seconds to consider an unreachable UPS as dead.DEADTIME 15# Location of the flag-file to make UPS turn itself off.POWERDOWNFLAG /etc/killpower# Warn every 12 hours if battery needs to be replaced.RBWARNTIME 43200# Warn every 5 minutes, if UPS is unreachable.NOCOMMWARNTIME 300# Wait 5 seconds before starting to shut down.FINALDELAY 5

We use this to send out remote commands by SSH to systems who’s power-lines
are connected to the UPSm but they don’t have Network UPS Tools installed and
so won’t be able to know by themselves when they should shutdown.

In the following example this will be a MikroTik device called “ap.example.com”

We assume that there is a user profile called nut on the remote device and
that it has a properly installed SSH public key. to allow password-less
logins.

When the power comes back, the UPS should reload the battery to a safe level,
before turning the power back on. By safe level, I mean: The battery must have
been charged enough that all devices can fully boot, and there would be still
enough power for the whole configured “Low Battery” time.

Without an appropriate re-charging delay, the power could come back just for a
short time (which is often the case in power-failures), the devices start to
boot up, but will be powered off again uncontrolled either during boot or
during shutdown.

Unfortunately this feature not supported on my UPS device model.

There might be features who provide similar functionality:

ups.delay.start

“Reboot Delay” time

“Minimum Charge” to return online

“Load On Delay” time (load.on.delay)

If I could, I would set my UPS to roughly charge double from what is needed by
the “Low Battery” time: