NUT setup with openSUSE

This page describes the configuration of an uninterruptible power supply (UPS) for a simple server operating unattended in an electrically unstable region. The configuration has been tested using the openSUSE GNU/Linux distribution.

1 — Introduction

I have several MGE/Eaton uninterruptible power supply (UPS) units which work well with openSUSE, but this was not an out-of-the-box experience. This page describes the required setup.

There are two basic strategies for stopping a server when building power fails:

Optimist
Keep going as long as possible with the available battery power. When the battery charge drops to 30%, stop the server. This is the most common strategy. When building power comes back, restart the server and hope that building power will last long enough to at least partially recharge the battery.
Pessimist
Shut down quickly as soon as building power fails. When building power comes back, restart the server, but be ready to stop again as soon as the building power fails again. Hope to be able to stop as often as the building power fails. Note: If you're living in a region with frequent short power outages, you'd be better served with a UPS that supports delaying restart of the load until the batteries have recharged to a certain minimum level. An entry-level MGE/Eaton Ellipse series UPS such as the one I use doesn't have that, but the MGE/Eaton Evolution does. This will guarantee that the system will always have enough battery power to complete a power-up and power-down sequence if the building power returns and fails again at the worst possible moment.

Since I live in a region with frequent short power outages, I choose the pessimist strategy, which is implemented in the UPS configuration files described in this page.

Figure 1 — An older Eaton Ellipse ASR 1500 USBS

The configuration for openSUSE 13.2 described by this page also works for openSUSE 11.2, 11.3 and 12.1. OpenSUSE 12.2 uses version 2.6.3 of NUT, 12.3 and 13.1 use version 2.6.5. 13.2 and 42.1 use 2.7.1.

1.1 — The UPS unit

When I bought the UPS unit used for this test it was called MGE (Merlin Gerin) Pulsar Ellipse ASR 1500 USBS and had reference number 66781. After the confusing merger of MGE and Eaton and an even more confusing re-assignment of the two companies' products, the unit is now known as the Eaton Ellipse ASR 1500 USBS but mercifully still has the same reference number 66781. According to Eaton, it has now (2012-04-23) been replaced by the Eaton Ellipse ECO 1600 FR USB.

Four of the eight sockets (the four at the back, visible in figure 1) are battery protected. The four on top, not visible, just have surge protection. A custom cable with an RJ45 connector at the UPS end (not visible in figure 1), plugs into a USB slot in the server. Read a summary of the features.

Figure 2 — Eaton Ellipse Max 1500 with fan

Read the installation and user manual This document is in 17 languages, its 12.9 Mbyte, but it still doesn't tell you what you need to know when you change the three batteries: to get those four deeply recessed screws out of the side cover, you will need a Torx T10 screwdriver. To remove the bottom plate, you have to remove the screw closest to the power inlet, since the screw goes through part of the bottom plate. The bottom plate is difficult to remove: I have yet to remove the bottom plate from one of these units without breaking at least one of the lugs which clip the bottom plate and the side plate together.

1.2 — Other UPS units

Eaton Ellipse Max 1500 — too noisy

In October 2012, I bought an Eaton Ellipse Max 1500, reference 68557, as shown in figure 2. This unit was formerly known as the Ellipse Max from MGE Office Protection Systems. I had a bad surprize when it arrived. I plugged it in and it made a lot of noise! Unlike the previous version by MGE of this UPS, the current model is slightly longer and is fitted with what must be the noisiest fan available in the whole of the People's Republic of China. You can see the vent in the picture. I see no reason whatsoever why such a UPS should make a noise permanently, even with no load. It's certainly not suitable for office use and I don't recommend it. It went back to the supplier the following day.

This would probably be a good UPS unit if the fan were of better quality and came on only when the unit got hot. In a €300 product it's reasonable to expect Eaton to provide some better quality engineering.

Curiously there is no mention on the Eaton web site or in the product documentation of the noise produced by this unit.

Eaton Ellipse Eco 1600 FR USB

Figure 3 — Eaton Ellipse Eco 1600 France

This is a basic product which provides battery backup for four of its eight sockets. the ones at the back. The USB cable supplied is only 1m20 long. I had to replace it with a longer cable for a more comfortable installation. It's good to see UPS manufacturers at last using well known cables.

As with many UPS units, it has two RJ45 sockets to be used to provide power-surge protection for Ethernet or telephone circuits. When used for telephone circuits, special cables will be needed with RJ11/12 plugs at one end and RJ45 plugs at the other. How are these to be wired? Testing shows that a straightforward wiring is incorrect. There is nothing on this subject in the documentation supplied.

1.3 — Change log

2012-04-20 — In file /etc/ups/upssched.conf moved upssched.pipe and upssched.lock from /var/lib/ups/upssched/ to /var/lib/ups/ to avoid creation of new directory.

2012-04-22 — Clarified the use of parameter RUN_AS_USER in files upssched.conf and upsmon.conf.

2012-05-15 — Restricted execution permission to user upsd in files /usr/sbin/upsd, /usr/sbin/upsmon, /usr/sbin/upssched, and upssched-cmd.

2012-09-23 — Updated for 12.2 use of NUT 2.6.3.

2012-10-31 — Added notes on Eaton 68557 and Eco 1600. Added section halt.local.

2013-03-30 — Added note on unexpected empty battery, check for low battery in upssched.conf with action in upssched-cmd. Use meaningful timer names.

2013-08-12 — Updated to cover release 12.3 and to add new systemd service unit for UPS shutdown. Added timers offdelay and ondelay to ups.conf.

2013-09-21 — Added bash script to provide UPS shutdown.

2013-12-09 — Updated for 13.1 use of NUT 2.6.5 and systemd handling of the automatic start of upsd.service.

2015-09-28 — Updated for 13.2 use of NUT 2.7.1. Better names for shutdown script and service. Specify full path in nut-driver.service. Improved trace of SHUTDOWNCMD. Added nut-journal.

2015-10-29 — Added nut-report. Added note on missing +EXEC in upsmon.conf. Added better checking for false low battery reports in upssched-cmd. Added section on setting battery.charge.low.

2015-11-23 — More tuning for false low battery reports in upssched-cmd and upssched.conf. Added low-battery-timer.

2 — The software

The software used is the GPL version 2 licenced Network UPS Tools (NUT) project version 2.7.1 which is distributed by openSUSE as an RPM package.

The configuration files are to be found in directory /etc/ups/. Certain run-time files are in /var/lib/ups/ and there is a useful script at /usr/sbin/. OpenSUSE releases 12.2, 12.3, 13.1 and 13.2 require either an additional systemd service unit file in /etc/systemd/system/ or a systemd script nut-delayed-ups-shutdown.sh in /usr/lib/systemd/system-shutdown.

Table 1 — Permissions and ownership of key files
Permissions Owner Group Name Purpose Use
Files provided by NUT
drwxr-xr-x root root /etc/ups/ Directory
-rw-r--r-- root root /etc/ups/hosts.conf CGI programs Not used
-rw-r--r-- root root /etc/ups/nut.conf General
-rw-r--r-- root root /etc/ups/ups.conf Define UPSs
-rw------- upsd root /etc/ups/upsd.conf Access control Use if no IPv6
-rw------- upsd root /etc/ups/upsd.users Network users
-rw------- upsd root /etc/ups/upsmon.conf Monitoring
-rw-r--r-- root root /etc/ups/upssched.conf Commands
-rw-r--r-- root root /etc/ups/upsset.conf Web access Not used
drwx------ upsd daemon /var/lib/ups/ Directory
-rwxr--r-- upsd daemon /usr/sbin/upsd Binary
-rwxr--r-- upsd daemon /usr/sbin/upsmon Binary
-rwxr--r-- upsd daemon /usr/sbin/upssched Binary
-rwxr-xr-x root root /bin/upssched-cmd Sample script Not used
Custom scripts for NUT
-rwxr--r-- upsd daemon /usr/sbin/upssched-cmd Pessimist
strategy script
-rwxr-xr-x root root /usr/bin/nut-journal journalctl helper
-rwxr-xr-x root root /usr/bin/nut-report Helper for
problem reports
systemd services required by NUT
-rw-r--r-- root root /usr/lib/systemd/system/nut-driver.service Calls upsdrvctl Needs fixing
-rw-r--r-- root root /usr/lib/systemd/system/nut-monitor.service Calls upsmon
-rw-r--r-- root root /usr/lib/systemd/system/nut-server.service Calls upsd
-rw-r--r-- root root /etc/systemd/system/
nut-delayed-ups-shutdown.service
systemd
service unit
Choose one
of these
-rwxr--r-- root root /usr/lib/systemd/system-shutdown/
nut-delayed-ups-shutdown.sh
UPS shutdown
script
-rwxr-xr-x root root /usr/lib/systemd/system-shutdown/
nutshutdown
openSUSE UPS
shutdown script
Not used
TCP wrapper files used by NUT
-rw-r--r-- root root /etc/hosts.allow TCP wrappers
access control
-rw-r--r-- root root /etc/hosts.deny TCP wrappers
access control
Not used

3 — Setup and the Race

The setup is for a simple configuration with one UPS providing protection for one server. There is no remote access and no web access. If remote access is needed, then the sysadmin has to use SSH to tunnel to the server to which the UPS is attached, and then use the commands available to the local administrator.

Some background : When wall power fails, a UPS unit will shut down a simple desktop PC, and this is sufficient, but shutting down a server is more complex. It must be shut down in such a way that when wall power returns, the server is turned back on again without human intervention.

The technique for doing this relies on a UPS unit which detects that wall power has come back and restarts the server. For this process to work, the UPS unit must receive a delayed-UPS-shutdown signal which will put it into a state where it can detect that wall power has returned and restart the server. A UPS unit which is simply left "beeping" will not restart its load when wall power returns.

3.1 — The race

It is important to distinguish clearly between the shutdown of the server, system shutdown, and the shutdown of the UPS unit. These are two separate actions. The following table summarises the techniques I use, but other techniques are possible.

System shutdown versus UPS shutdown
Commanded by When
Server
shutdown
SHUTDOWNCMD in upsmon.conf
e.g. /sbin/shutdown -h +0
Decided by time-out in script
upssched-cmd
These two shutdowns
race. We want the
server to win.
UPS
shutdown
systemd service unit
nut-delayed-ups-shutdown.service
e.g. upsdrvctl shutdown
offdelay seconds after execution
of service unit. See ups.conf.

The UPS delayed shutdown order to be sent to the UPS unit is not an immediate order. If it were, the UPS would turn off immediately causing power loss and probable loss of data in the server. The order used is for a delayed shutdown, with a default delay of 20 seconds specified in ups.conf. This may be sufficient to allow the server to shutdown before the UPS, but there is no guarantee of this. The UPS and the server race to shutdown. We hope the server wins.

3.1.1 — Service unit UPS shutdown

Some simple ascii art shows the timing for a 13.1 test rig and the service unit UPS shutdown of chapter 5.13:

 systemctl               system
 poweroff                 halt
     |     |XXXXXXXXXXXXXXXX|
     0   2 | 4   6   8  10  12  14  16  18  20  22  24  26  28  30  32 secs
           |                                       |
        upsdrvctl                                 UPS
        shutdown                                shutdown

3.1.2 — Scripted UPS shutdown

There is an alternative technique for shutting down the UPS, using a Bash script rather than a systemd service unit. This shortens the race. Some more ascii art shows the timing of the same 13.1 basic test rig and the scripted shutdown of chapter 5.14. The X's show the race window:

 systemctl               system
 poweroff                 halt
     |                 |XXXX|
     0   2   4   6   8 |10  12  14  16  18  20  22  24  26  28  30  32 secs
                       |                                       |
                   upsdrvctl                                  UPS
                   shutdown                                 shutdown

In the example shown for 13.1, the script solution has the advantage of reducing the race window from 9 to 3 secs. Note that the same security can also be achieved by the service unit by setting offdelay = 26 in ups.conf.

The service unit solution has been considered a really bad idea in systemd discussions since it calls upsdrvctl shutdown so early in the shutdown sequence.

You should chose one or the other of these solutions - not both.

4 — Documentation

The sample configuration files provided by the NUT project contain detailed descriptions of the use of each file. Hint: make a copy of the /etc/ups directory before making changes. You will find further documentation at /usr/share/doc/packages/nut, and on the NUT project site.

The NUT Developer's Guide includes a very helpful diagram showing how the components of NUT fit together.

5 — Configuration

5.1 — nut.conf

The general section of the NUT configuration determines which part of the NUT is to be started.

The standalone mode calls for a local only configuration, with 1 UPS protecting the local system. This implies starting the 3 NUT layers (driver, upsd and upsmon) and the matching configuration files.

  # /etc/ups/nut.conf
  MODE=standalone

13.2: Note that there are no spaces around the "=". This file is intended to be sourced by shell scripts.

5.2 — ups.conf

Specify and name the UPS which will provide the protection.

As from openSUSE 12.2, the UPS unit poweroff is called for by a systemd service unit. This is executed early in the shutdown sequence, and in a slow machine the default 20 seconds before UPS shutdown may not be enough to allow system shutdown. The usbhid-ups driver provides options to specify the time intervals before UPS unit poweroff and poweron. See man usbhid-ups for details.

As from openSUSE 13.2, an additional delay occurs in the system shutdown which must be taken into account: The console trace shows A stop job is running for wicked network management interfaces (30 sec). To avoid the risk of turning off the UPS before the server stops, I increased the offdelay and ondelay times by 30 seconds.

Here are the values I use:

  # /etc/ups/ups.conf
  # Make sure name matches in /usr/sbin/upssched-cmd and /etc/ups/upsmon.conf
  [Eaton]
     driver = usbhid-ups
     port = auto
     desc = "Eaton Ellipse ECO 1600"
     vendorid = 0463
     offdelay = 60
     ondelay = 70

5.3 — upsd.conf

Specify which ports the upsd daemon will listen on. By default, openSUSE 12.3, 13.1 and 13.2 enable IPv6 so specify:

  # /etc/ups/upsd.conf
  # Make sure this matches the IPv6 setting in YaST => Network Devices =>
  # Network Settings => Global options => IPv6 Protocol Settings
  # LISTEN <address> [<port>]
  LISTEN 127.0.0.1 3493
  LISTEN ::1 3493

If you disenable IPv6 using YaST => Network Devices => Network Settings => Global options => IPv6 Protocol Settings, then specify only:

  # /etc/ups/upsd.conf
  # LISTEN <address> [<port>]
  LISTEN 127.0.0.1 3493
  # IPv6 turned off

Note: The logic of file upsd.conf is subtle. If no LISTEN addresses are specified in upsd.conf, the compiled in defaults are used. As soon as you specify one or more LISTEN directives, upsd will only listen to the specified addresses.

Thus if both IPv4 and IPv6 LISTEN directives are commented out

  # /etc/ups/upsd.conf
  # LISTEN <address> [<port>]
  # LISTEN 127.0.0.1 3493
  # LISTEN ::1 3493

then NUT listens to 127.0.0.1 and ::1 as shown by /var/log/messages (Pre-13.2) or journalctl (13.2)

  Nov 10 09:52:41 glacon2 usbhid-ups[15911]: Startup successful
  Nov 10 09:52:41 glacon2 upsd[15914]: listening on 127.0.0.1 port 3493
  Nov 10 09:52:41 glacon2 upsd[15914]: listening on ::1 port 3493
  Nov 10 09:52:41 glacon2 upsd[15914]: Connected to UPS [Eaton]: usbhid-ups-Eaton

But if only ::1 is commented out

  # /etc/ups/upsd.conf
  # LISTEN <address> [<port>]
  LISTEN 127.0.0.1 3493
  # LISTEN ::1 3493

then NUT only listens to 127.0.0.1

  Nov 10 09:34:24 glacon usbhid-ups[4282]: Startup successful
  Nov 10 09:34:24 glacon upsd[4285]: listening on 127.0.0.1 port 3493
  Nov 10 09:34:24 glacon upsd[4285]: Connected to UPS [Eaton]: usbhid-ups-Eaton

5.4 — upsd.users

There are no network users, but we must still define a local user who has access to the UPS monitoring. This will be needed for the MONITOR declaration in upsmon.conf The value I use is

  # upsd.users
  [upsmaster]
        password = sekret
        upsmon master

You may want something better than sekret as a password.

5.5 — upsmon.conf

By default, upsmon splits into two processes. One stays as root and waits to run the SHUTDOWNCMD. The other one switches to user upsd and does everything else. This file configures these two processes. Here is a summary of the possible entries:

Here, finally are the values I used:

 # /etc/ups/upsmon.conf
 # Make sure name matches in /usr/sbin/upssched-cmd and /etc/ups/ups.conf
 MONITOR Eaton@localhost 1 upsmaster sekret master
 MINSUPPLIES 1
 SHUTDOWNCMD "logger -t upsmon.conf \"SHUTDOWNCMD calling /sbin/shutdown to shut down system\" ; /sbin/shutdown -h +0"
 NOTIFYCMD /usr/sbin/upssched
 POLLFREQ 5
 POLLFREQALERT 5
 HOSTSYNC 15
 DEADTIME 15
 POWERDOWNFLAG /etc/killpower

 # You can change the default messages to something else if you like.
 # NOTIFYMSG notifytype "message"
 # where %s is replaced with the identifier of the UPS in question.

 NOTIFYMSG COMMBAD	"UPS %s: Communications lost +++ Perdu contact avec l'onduleur."
 NOTIFYMSG COMMOK	"UPS %s: Communications (re-)established +++ Onduleur retrouve'."
 NOTIFYMSG FSD		"UPS %s: Forced shutdown in progress +++ Arret obligatoire en cours."
 NOTIFYMSG LOWBATT	"UPS %s: Battery is low +++ Batterie se vide."
 NOTIFYMSG NOCOMM	"UPS %s: Not available +++ Onduleur indisponible."
 NOTIFYMSG NOPARENT	"upsmon parent process died - shutdown impossible."
 NOTIFYMSG ONBATT	"UPS %s: On battery +++ Onduleur sur batterie."
 NOTIFYMSG ONLINE	"UPS %s: On line power +++ Onduleur sur secteur."
 NOTIFYMSG REPLBATT	"UPS %s: Battery needs to be replaced +++ Batterie d'onduleur a` remplacer."
 NOTIFYMSG SHUTDOWN	"Auto logout and shutdown proceeding +++ Arret automatique en cours."

 NOTIFYFLAG COMMBAD  SYSLOG+EXEC
 NOTIFYFLAG COMMOK   SYSLOG+EXEC
 NOTIFYFLAG FSD      SYSLOG+WALL+EXEC
 NOTIFYFLAG LOWBATT  SYSLOG+WALL+EXEC
 NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
 NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
 NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
 NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
 NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
 NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC

 RBWARNTIME 43200
 NOCOMMWARNTIME 300
 FINALDELAY 5

5.6 — upssched.conf

This file specifies the timer actions associated with the UPS events. It works in close cooperation with the script upssched-cmd.

Here, finally, are the values I used for this configuration file:

 # /etc/ups/upssched.conf
 # See also /usr/sbin/upssched-cmd

 CMDSCRIPT /usr/sbin/upssched-cmd

 PIPEFN /var/lib/ups/upssched.pipe
 LOCKFN /var/lib/ups/upssched.lock

 # Define timer to give two minute warning
 AT ONBATT * START-TIMER two-minute-warning-timer 5
 # Define timer to give one minute warning
 AT ONBATT * START-TIMER one-minute-warning-timer 65
 # Define timer to shut down box
 AT ONBATT * START-TIMER shutdown-timer 125
 
 ## Alternative timer definitions for a faster shutdown
 #AT ONBATT * START-TIMER one-minute-warning-timer 5
 #AT ONBATT * START-TIMER shutdown-timer 65

 # Turn off timers if power comes back
 AT ONLINE * CANCEL-TIMER two-minute-warning-timer
 AT ONLINE * CANCEL-TIMER one-minute-warning-timer
 AT ONLINE * CANCEL-TIMER shutdown-timer
 AT ONLINE * EXECUTE ups-back-on-line

 # Defective UPS runs down on its own for no reason!
 AT LOWBATT * START-TIMER low-battery-timer 5
 AT LOWBATT * START-TIMER shutdown-timer 65

5.7 — /usr/sbin/upssched-cmd

upssched-cmd is a script for handling timer completion and other events. It works in close cooperation with the configuration file upssched.conf which specifies the timers. NUT provides a script /bin/upssched-cmd which is minimal and is not used in the configuration described here.

The script provided here is adapted from a complete script supplied by MGE with the UPS when I bought it. The MGE script addressed the optimist strategy described in the Introduction but the version given here implements the pessimist strategy.

I placed this script in the directory /usr/sbin to emphasize its nature. It's not an executable for the ordinary user. Although it isn't a binary file, it shouldn't be in /bin.

#!/bin/bash -u
# /usr/sbin/upssched-cmd
# Adapted from code supplied by MGE.
# See also /etc/ups/upssched.conf
# &1 is the name of the timer which has just expired

# Debugging: Log all calls to this script
logger -i -t upssched-cmd Calling upssched-cmd $1

# Make sure this corresponds to declaration in /etc/ups/ups.conf
UPS="Eaton@localhost"
# What is the current battery charge?
CHARGE=`upsc $UPS battery.charge`
if [[ $? -ne 0 ]]
then logger -i -t upssched-cmd "Configuration error: unable to read charge of UPS $UPS"
fi
LOW=`upsc $UPS battery.charge.low`
STATUS=`upsc $UPS ups.status`
CHMSG="$STATUS $CHARGE%"

# Messages to be put in front of the users
MSG0="Power back, $CHMSG - shutdown cancelled. +++ Secteur de retour - arret abandonne."
MSG2="Running on battery, $CHMSG - possible shutdown in 2 minutes - save your work! +++ Sur batterie - arret possible en 2 minutes - sauvez votre travail!"
MSG3="Running on battery, $CHMSG - probable shutdown in 1 minute - save your work now! +++ Sur batterie - arret en 1 minute - sauvez votre travail maintenant!"
# On low battery, turn off box in 30 seconds
# Check that timer value matches AT LOWBATT * START-TIMER shutdown-timer
MSG4="Low battery, $CHMSG - probable shutdown in 30 secs - save your work now! +++ Batterie dechargee - arret en 30 sec - sauvez votre travail maintenant!"

# Where does openSUSE hide stuff?
sbinPath="/usr/sbin/"

# The basic strategy is: Do not shutdown based on battery runtime 
# or charge since the "quick shutdown" strategy does not rely on 
# measuring the battery charge.  All shutdowns are based on elapsed time.
# However experience shows that some UPS units mysteriously
# loose their charge for no apparent reason.  In this case, we
# assume an emergency situation and in upssched.conf we call for 
# a quick shutdown using the timers "low-battery-timer" and "shutdown-timer".
case $1 in
   # Handle warning timers
   two-minute-warning-timer)
      logger -i -t upssched-cmd "Two minute warning timeout reached, $CHMSG"
      echo $MSG2 | wall
   ;;
   one-minute-warning-timer)
      logger -i -t upssched-cmd "One minute warning timeout reached, $CHMSG"
      echo $MSG3 | wall
   ;;
   # Handle shutdown timer. When triggered,
   # timer has expired, so immediately shutdown.
   shutdown-timer)
      logger -i -t upssched-cmd "Shutdown timer reached: Calling upsmon -c fsd, $CHMSG"
      ${sbinPath}upsmon -c fsd
   ;;
   ups-back-on-line)
      logger -i -t upssched-cmd "ups_back-on-line: removing timers, $CHMSG"
      echo $MSG0 | wall
   ;;
   # Defective UPS signals low charge for no reason.
   # Note: to change the default low battery charge to say 36:
   # upsrw -s battery.charge.low=36 -u upsmaster -p sekret my-ups
   low-battery-timer)
      logger -i -t upssched-cmd "$MSG4"
      echo $MSG4 | wall
   ;;
   *)
      logger -i -t upssched-cmd "Unrecognized command: \"$1\", $CHMSG"
   ;;
esac

5.8 — hosts.allow or how to avoid [ERR ACCESS-DENIED]

NUT uses TCP-Wrappers to provide controlled access to the daemon upsd. Access control is applied to NUT clients specified in upsd.users. The TCP-Wrappers support is optional in NUT but is included in the openSUSE 12.3, 13.1 and 13.2 packaging of NUT. NUT works directly with TCP-Wrappers and does not require the super-daemon inetd, which is not used by openSUSE 12.3, 13.1 or 13.2.

Unfortunately this non-use of inetd means that the very useful wrapper test programs tcpdchk and tcpdmatch which assume that the inetd daemon is present are not available to test your configuration.

See man tcpd, man -S5 hosts_access and man -S5 hosts_options for a detailed description of /etc/hosts.allow and /etc/hosts.deny. These last two man pages have been removed from 13.2. Try the Internet or an earlier distribution.

As from 13.2 TCP-Wrappers are being abandoned, but the package is still loaded. See the OpenSUSE forum discussion of TCP Wrappers as abandonware.

The two files hosts.allow and hosts.deny provide a powerful means of controlling access, providing precision of access control not available with firewalls. The mechanism is based on rules for what is allowed and what is to be denied. In my simple configuration I explicitly state for each rule whether it is an ALLOW rule or a DENY rule, and I place all the rules in the file hosts.allow. I have no hosts.deny file; since I rename the example provided by SuSE.

The rules have two forms, basic and debugging:

Finally, here are the relevant parts of my /etc/hosts.allow

 # /etc/hosts.allow
 # 2010-10-03   Roger Price
 # Notes:
 # 1. See `man tcpd', `man -S5 hosts_access' and `man -S5 hosts_options'
 #    for a detailed description of /etc/hosts.allow and /etc/hosts.deny.
 # 2. This file contains both the authorisations and the denials.
 #    The option ALLOW or DENY is explicit on each rule.
 # 3. The file hosts.deny is no longer used.

 ...

 upsd : localhost, LOCAL, 127.0.0.1,    [::1]               : ALLOW
 upsd : ALL :  spawn (/bin/mail -r hosts.allow@localhost\
                      -s '%s@%h (glacon2) refused access to %d from %c'\
                      roger@localhost) &                    : DENY       

 ...

 # And now the denials which previously appeared in /etc/hosts.deny
 #
 ALL :  ALL                                                 : DENY

See man tcpd, man -S5 hosts_access for a detailed description of hosts.allow and hosts.deny. See also man -S5 hosts_options for additional options to the rules.

5.9 — hosts.deny

This file is not used and is not present in my configuration. All denials are specified in hosts.allow.

5.10 — nut-server.service

Like the alien plant in the Quatermass Experiment, systemd is spreading throughout openSUSE. In 13.2, the NUT server, monitor and driver become systemd service units. These are defined by openSUSE and are not a part of the NUT source code. In /usr/lib/systemd/system we now find the power devices information server:

 [Unit]
 Description=Network UPS Tools - power devices information server
 After=local-fs.target network.target nut-driver.service
 Requires=nut-driver.service
 Before=nut-monitor.service

 [Service]
 ExecStart=/usr/sbin/upsd 
 Type=forking

 [Install]
 WantedBy=multi-user.target

You can get the status of this service at any time:

 pinta:~ # systemctl status nut-server.service
 nut-server.service - Network UPS Tools - power devices information server
    Loaded: loaded (/usr/lib/systemd/system/nut-server.service; enabled)
    Active: active (running) since Sun 2015-10-04 22:12:32 CEST; 11h ago
   Process: 1717 ExecStart=/usr/sbin/upsd (code=exited, status=0/SUCCESS)
  Main PID: 1718 (upsd)
    CGroup: /system.slice/nut-server.service
            └─1718 /usr/sbin/upsd

 Oct 04 22:12:32 pinta upsd[1718]: Startup successful
 Oct 04 22:12:32 pinta upsd[1718]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
 Oct 04 22:12:32 pinta upsd[1717]: fopen /var/lib/ups/upsd.pid: No such file or directory
 Oct 04 22:12:32 pinta upsd[1717]: listening on 127.0.0.1 port 3493
 Oct 04 22:12:32 pinta upsd[1717]: Connected to UPS [Eaton]: usbhid-ups-Eaton

The service needs to be enabled using Yast => System => Services Manager. Once enabled, it will be started automatically at each power-on by systemd.

It is also possible to stop and start the service at any time using the commands rcupsd stop and rcupsd start but this is deprecated by openSUSE.

5.11 — nut-monitor.service

In 13.2 openSUSE also defines the power devices monitor and shutdown controller. This is not a part of the NUT source code. In /usr/lib/systemd/system we now find:

 [Unit]
 Description=Network UPS Tools - power device monitor and shutdown controller
 After=local-fs.target network.target nut-server.service

 [Service]
 ExecStart=/usr/sbin/upsmon
 PIDFile=/var/run/upsmon.pid
 Type=forking

 [Install]
 WantedBy=multi-user.target

You can get the status of this service at any time:

 
 pinta:~ # systemctl status nut-monitor.service
 nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
    Loaded: loaded (/usr/lib/systemd/system/nut-monitor.service; enabled)
    Active: active (running) since Sun 2015-10-04 22:12:32 CEST; 12h ago
   Process: 1719 ExecStart=/usr/sbin/upsmon (code=exited, status=0/SUCCESS)
  Main PID: 1721 (upsmon)
    CGroup: /system.slice/nut-monitor.service
            ├─1720 /usr/sbin/upsmon
            └─1721 /usr/sbin/upsmon

 Oct 04 22:12:32 pinta upsmon[1720]: Startup successful
 Oct 04 22:12:32 pinta upsmon[1719]: fopen /var/run/upsmon.pid: No such file or directory
 Oct 04 22:12:32 pinta upsmon[1719]: UPS: Eaton@localhost (master) (power value 1)
 Oct 04 22:12:32 pinta upsmon[1719]: Using power down flag file /etc/killpower

The service needs to be enabled using Yast => System => Services Manager. Once enabled, it will be started automatically at each power-on by systemd. Note that there are two instances of upsmon running, one owned by root to execute SHUTDOWNCMD, the other owned by upsd to do the rest of tthe work.

5.12 — nut-driver.service

In 13.2 openSUSE also defines the power device driver controller. This is not a part of the NUT source code. In /usr/lib/systemd/system we now find:

 [Unit]
 Description=Network UPS Tools - power device driver controller
 After=local-fs.target network.target
 StopWhenUnneeded=yes

 [Service]
 ExecStart=/upsdrvctl start
 ExecStop=/upsdrvctl stop
 Type=forking

This service unit is broken, the ExecStart and ExecStop lines should read:

 # Make explicit that upsdrvctl is in /usr/lib/ups/driver/
 ExecStart=/usr/lib/ups/driver/upsdrvctl start
 ExecStop=/usr/lib/ups/driver/upsdrvctl stop

You will have to make this change yourself. Once repaired, you can get the status of this service at any time:

 pinta:~ # systemctl status nut-driver.service
 nut-driver.service - Network UPS Tools - power device driver controller
    Loaded: loaded (/usr/lib/systemd/system/nut-driver.service; static)
    Active: active (running) since Sun 2015-10-04 22:12:32 CEST; 12h ago
   Process: 1493 ExecStart=/usr/lib/ups/driver/upsdrvctl start (code=exited, status=0/SUCCESS)
  Main PID: 1716 (usbhid-ups)
    CGroup: /system.slice/nut-driver.service
            └─1716 /usr/lib/ups/driver/usbhid-ups -a Eaton 

 Oct 04 22:12:30 pinta upsdrvctl[1493]: Using subdriver: MGE HID 1.32
 Oct 04 22:12:30 pinta upsdrvctl[1493]: Network UPS Tools - Generic HID driver 0.38 (2.7.1)
 Oct 04 22:12:30 pinta upsdrvctl[1493]: USB communication driver 0.32
 Oct 04 22:12:32 pinta usbhid-ups[1716]: Startup successful
 Oct 04 22:12:32 pinta upsdrvctl[1493]: Network UPS Tools - UPS driver controller 2.7.1

You do not need to enable this service.

5.13 — nut-delayed-ups-shutdown.service

This systemd service unit calls for a delayed UPS shutdown. The delay is specified by ups.conf This systemd service is not a part of NUT and is not provided by openSUSE. You have to create it yourself. The unit is the new file /etc/systemd/system/nut-delayed-ups-shutdown.service :

 # nut-delayed-ups-shutdown.service

 # OpenSUSE 12.3, 13.1, 13.2 powerdown: server shutdown requires UPS shutdown
 # This service fixes a problem with openSUSE 12.3, 13.1, 13.2 NUT.
 # Background: When wall power fails the system and the UPS must
 # be shut down in such a way that when wall power returns,
 # the server is turned back on again without human intervention.

 # For this process to work, the UPS unit must receive a
 # delayed-UPS-shutdown signal which will put it into a state where
 # it will restart the server when wall power returns. A UPS unit 
 # which is simply left beeping will not restart its load when wall 
 # power returns.

 [Unit]
 Description=Initiate delayed UPS shutdown
 Before=umount.target
 DefaultDependencies=no

 [Service]
 Type=oneshot
 ExecStart=/usr/bin/logger -t upsdrvctl "nut-delayed-ups-shutdown.service calling upsdrvctl to shut down UPS unit"
 ExecStart=/usr/lib/ups/driver/upsdrvctl shutdown

 [Install]
 WantedBy=final.target

The service needs to be enabled using Yast => System => Services Manager. Once enabled, it will be started automatically by systemd at each system shutdown. To enable the service pre-13.2, use command

 pinta:~ # systemctl --system reenable /etc/systemd/system/nut-delayed-ups-shutdown.service
 ln -s '/etc/systemd/system/nut-delayed-ups-shutdown.service'
             '/etc/systemd/system/final.target.wants/nut-delayed-ups-shutdown.service'

It's status is normally:

 pinta:~ # systemctl status nut-delayed-ups-shutdown.service
 nut-delayed-ups-shutdown.service - Initiate delayed UPS shutdown
    Loaded: loaded (/etc/systemd/system/nut-delayed-ups-shutdown.service; enabled)
    Active: inactive (dead)

There is an alternative to this service; a Bash script described in the next chapter. For a discussion of the two techniques, and the race involved, see Setup and the Race.

5.14 — nut-delayed-ups-shutdown.sh

This alternative technique for delayed shutdown of the UPS uses a Bash script. As with the service, the delay is specified by ups.conf. You either use the service or the script, one or the other, not both.

systemd provides drop-in directories for scripts which should be executed as late as possible during a system shutdown. /usr/lib/systemd/system-shutdown is for a user's scripts, and /lib/systemd/system-shutdown is for system scripts. Although shutting down a UPS unit is clearly a system matter and not a user matter, I use the /usr/lib/... directory since my script is not part of an officially distributed product.

openSUSE 13.2 provides a delayed shutdown script for NUT in /usr/lib/systemd/system-shutdown/nutshutdown . I have not tested and do not use this script which I have commented out.

systemd detects automatically that a script in one of these drop-in directories needs to be executed. There is no need to enable the script.

Place the following script nut-delayed-ups-shutdown.sh in /usr/lib/systemd/system-shutdown : Note: in openSUSE release 12.2 there is no /usr/lib... so you have to choose /lib/...

 #! /bin/bash
 # nut-delayed-ups-shutdown.sh  Delayed turn off for the UPS unit.
 # Needed for automatic system restart when wall power returns.
 UPSDRVCTL_BIN=/usr/lib/ups/driver/upsdrvctl
 $UPSDRVCTL_BIN shutdown

There is no need to enable the script and no trace in /var/log/messages or journalctl of the action of this script. The only evidence is that the UPS shuts down. For a further discussion of the two shutdown techniques, and the race involved, see Setup and the Race.

5.15 — journalctl helper nut-journal

Extracting the NUT activity logged by journald can be laborious since the information is diluted by all the other activity that gets logged. This Bash helper script picks out the journald entries generated by NUT activity during the previous complete boot through shutdown sequence, and the current boot. This script is not a part of NUT or openSUSE. I placed it in directory /usr/bin/ .

 #! /bin/bash
 # nut-journal Display NUT activity recorded by journald for
 # previous complete boot and current (unfinished) boot.
 # RP 2015-10-27

 TEMPFILE=`mktemp`
 JOURNALCTL=journalctl
 NUT_ACTIVITY="upsd|upsmon|upssched|upsdrvctl"

 WHEREIS=`whereis -b $JOURNALCTL`
 if [[ "$WHEREIS" == "$JOURNALCTL:" ]]
 then echo "Sorry, I cannot find the program $JOURNALCTL needed to run this script."
      exit 1
 fi

 # Does user have access to journalctl for upsd?
 $JOURNALCTL -b 0 -n 10 --no-pager > /dev/null
 if [ $? -eq 0 ]; then : 
    else echo "        Welcome to nut-journal"
         echo "You do not seem to have access to the journal"
         echo "for system commands such as those of NUT."
         echo "Ask your system administrator to add your"
         echo "account to the systemd-journal group."
         echo "When this is done, log out and then log in"
         echo "and try again."  
         exit 1
 fi

 echo "        Previous complete boot through shutdown" > $TEMPFILE
 $JOURNALCTL -b -1 --no-pager | grep -E $NUT_ACTIVITY >> $TEMPFILE
 # Include Journal stopped message
 $JOURNALCTL -b -1 -n 1 --no-pager | tail -n 1 >> $TEMPFILE
 echo "        Current boot" >> $TEMPFILE
 $JOURNALCTL -b  0 --no-pager | grep -E $NUT_ACTIVITY >> $TEMPFILE
 less $TEMPFILE
 rm $TEMPFILE

Don't forget to make the script executable.

Here is an example of the output of nut-journal for a short test run. It begins with the initialization of upsd :

         Previous complete boot through shutdown
 Oct 06 22:46:07 pinta upsdrvctl[1508]: Using subdriver: MGE HID 1.32
 Oct 06 22:46:07 pinta upsdrvctl[1508]: Network UPS Tools - Generic HID driver 0.38 (2.7.1)
 Oct 06 22:46:07 pinta upsdrvctl[1508]: USB communication driver 0.32
 Oct 06 22:46:08 pinta upsd[1732]: listening on 127.0.0.1 port 3493
 Oct 06 22:46:08 pinta upsd[1732]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:46:08 pinta upsd[1733]: Startup successful
 Oct 06 22:46:08 pinta upsmon[1735]: Startup successful
 Oct 06 22:46:08 pinta upsd[1733]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:46:08 pinta upsd[1733]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
 Oct 06 22:46:08 pinta upsd[1733]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:46:08 pinta hosts.allow[1740]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:46:08 pinta hosts.allow[1742]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:46:09 pinta upsdrvctl[1508]: Network UPS Tools - UPS driver controller 2.7.1
 Oct 06 22:46:09 pinta upsd[1732]: fopen /var/lib/ups/upsd.pid: No such file or directory
 Oct 06 22:46:09 pinta upsd[1732]: listening on 127.0.0.1 port 3493
 Oct 06 22:46:09 pinta upsd[1732]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:46:09 pinta upsmon[1734]: fopen /var/run/upsmon.pid: No such file or directory
 Oct 06 22:46:09 pinta upsmon[1734]: UPS: Eaton@localhost (master) (power value 1)
 Oct 06 22:46:09 pinta upsmon[1734]: Using power down flag file /etc/killpower

Now we see the trace of the shutdown:

 Oct 06 22:47:43 pinta upsmon[1736]: UPS Eaton@localhost: On battery +++ Onduleur sur batterie
 Oct 06 22:47:43 pinta upssched[1821]: Timer daemon started
 Oct 06 22:47:44 pinta upssched[1821]: New timer: two-minute-warning-timer (5 seconds)
 Oct 06 22:47:44 pinta upssched[1821]: New timer: one-minute-warning-timer (65 seconds)
 Oct 06 22:47:44 pinta upssched[1821]: New timer: shutdown-timer (125 seconds)
 Oct 06 22:47:49 pinta upssched[1821]: Event: two-minute-warning-timer
 Oct 06 22:47:49 pinta upssched-cmd[1823]: Calling upssched-cmd two-minute-warning-timer
 Oct 06 22:47:49 pinta upssched-cmd[1826]: Two minute warning timeout reached, OB DISCHRG 88%
 Oct 06 22:48:49 pinta upssched[1821]: Event: one-minute-warning-timer
 Oct 06 22:48:49 pinta upssched-cmd[1830]: Calling upssched-cmd one-minute-warning-timer
 Oct 06 22:48:49 pinta upssched-cmd[1833]: One minute warning timeout reached, OB DISCHRG 86%
 Oct 06 22:49:49 pinta upssched[1821]: Event: shutdown-timer
 Oct 06 22:49:49 pinta upssched-cmd[1837]: Calling upssched-cmd shutdown-timer
 Oct 06 22:49:49 pinta upssched-cmd[1840]: Shutdown timer reached: Calling upsmon -c fsd, OB DISCHRG 84%
 Oct 06 22:49:49 pinta upsmon[1736]: Signal 10: User requested FSD
 Oct 06 22:49:49 pinta upsd[1733]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:49:49 pinta upsd[1733]: Client upsmaster@127.0.0.1 set FSD on UPS [Eaton]
 Oct 06 22:49:49 pinta upsmon[1736]: Executing automatic power-fail shutdown
 Oct 06 22:49:49 pinta hosts.allow[1843]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:49:49 pinta upsmon[1736]: Auto logout and shutdown proceeding +++ Arret automatique en cours
 Oct 06 22:49:54 pinta upsmon.conf[1849]: SHUTDOWNCMD calling /sbin/shutdown to shut down system
 Oct 06 22:49:54 pinta upsd[1733]: mainloop: Interrupted system call
 Oct 06 22:49:54 pinta upsd[1733]: Signal 15: exiting
 Oct 06 22:49:54 pinta nut-delayed-ups-shutdown[1854]: nut-delayed-ups-shudown.service calling upsdrvctl to shut down UPS unit
 Oct 06 22:49:54 pinta upsdrvctl[1892]: Network UPS Tools - UPS driver controller 2.7.1
 Oct 06 22:49:58 pinta upsdrvctl[1885]: Using subdriver: MGE HID 1.32
 Oct 06 22:49:58 pinta upsdrvctl[1885]: Network UPS Tools - Generic HID driver 0.38 (2.7.1)
 Oct 06 22:49:58 pinta upsdrvctl[1885]: USB communication driver 0.32
 Oct 06 22:49:59 pinta upsdrvctl[1885]: Initiating UPS shutdown
 Oct 06 22:49:59 pinta upsdrvctl[1885]: Network UPS Tools - UPS driver controller 2.7.1
 Oct 06 22:50:02 pinta systemd-journal[477]: Journal stopped

Finally we see the upsd initialization of the current boot:

         Current boot
 Oct 06 22:52:22 pinta upsdrvctl[1530]: Using subdriver: MGE HID 1.32
 Oct 06 22:52:22 pinta upsdrvctl[1530]: Network UPS Tools - Generic HID driver 0.38 (2.7.1)
 Oct 06 22:52:22 pinta upsdrvctl[1530]: USB communication driver 0.32
 Oct 06 22:52:23 pinta upsd[1754]: listening on 127.0.0.1 port 3493
 Oct 06 22:52:23 pinta upsd[1754]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:52:23 pinta upsd[1755]: Startup successful
 Oct 06 22:52:23 pinta upsmon[1757]: Startup successful
 Oct 06 22:52:23 pinta upsd[1755]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:52:23 pinta upsd[1755]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
 Oct 06 22:52:23 pinta hosts.allow[1762]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:52:23 pinta upsd[1755]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:52:23 pinta hosts.allow[1764]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:52:23 pinta upsdrvctl[1530]: Network UPS Tools - UPS driver controller 2.7.1
 Oct 06 22:52:23 pinta upsd[1754]: fopen /var/lib/ups/upsd.pid: No such file or directory
 Oct 06 22:52:23 pinta upsd[1754]: listening on 127.0.0.1 port 3493
 Oct 06 22:52:23 pinta upsd[1754]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:52:23 pinta upsmon[1756]: fopen /var/run/upsmon.pid: No such file or directory
 Oct 06 22:52:23 pinta upsmon[1756]: UPS: Eaton@localhost (master) (power value 1)
 Oct 06 22:52:23 pinta upsmon[1756]: Using power down flag file /etc/killpower

5.16 — Filing a report nut-report

The best way to file a report about the use of NUT is in the Nut-upsuser mailing list. If you wish to show your current configuration, then I suggest you use the utility script nut-report to prepare a condensed display of your configuration. This script is not a part of NUT or openSUSE. I placed it in directory /usr/bin/ .

The script creates a file /tmp/NUT.report with a summary of your NUT configuration. Passwords have been removed. To submit this report to the Nut-upsuser mailing list, either place it on a web server if you have access to one, or upload the file to a free file hoster such as filehosting.org and post the URL they give you together with your symptoms in the mailing list. To avoid any possible spam, you should use a throw-away e-mail address when uploading to the file hoster. Since Filehosting.org check for the the excellent and free Mailinator, I suggest you use myTrashMail.com which is a very similar service. Their throwaway email addresses are of the form anything@mt2015.com .

 #! /bin/bash
 # Report openSUSE NUT configuration
 # Remove comments, blank lines and passwords
 # 2015-10-16 RP

 D="/etc/ups"         # Where does openUSE hide stuff?
 T=`mktemp`           # Temporary file
 R="/tmp/NUT.report"  # T without passwords

 echo -e "        NUT configuration        `date --utc '+%Y-%m-%d %T %Z'`" > $T

 # Configuration files, remove comments and empty lines
 RE="^#.*$|^[[:space:]]*$"
 for F in $D/nut.conf $D/ups.conf $D/upsd.conf $D/upsd.users $D/upsmon.conf $D/upssched.conf /usr/sbin/upssched-cmd
 do echo -e "\n        ########### $F ###########" >> $T
   if [[ -f "$F" && -r "$F" ]] ; then
      cat $F | grep -v -E "$RE" >> $T
   else echo "Cannot access $F" >> $T
   fi
 done
 # Get upsd rules out of hosts.allow
 HA="/etc/hosts.allow"
 echo -e "\n        ########### $HA ###########" >> $T
 if [[ -f "$HA" && -r "$HA" ]] ; then
    grep -v -E "^#.*$|^[[:space:]]*$" < $HA |
    while read L || [[ -n "$L" ]]
    do if [[ "$L" =~ ^.*(upsd.*)$ ]]
       then TRIM=$L  # Bash removes unwanted white space
            echo $TRIM >> $T
       fi
    done
 else echo "Cannot access $HA" >> $T
 fi

 # Processes
 echo -e "\n        ########### ps aux ###########" >> $T
 ps aux | grep "/ups" | grep -v "grep" >> $T

 # Ownership and permissions
 echo -e "\n        ########### Ownership and permissions ###########" >> $T
 ls -alF /usr/sbin/ups* >> $T
 ls -alF /etc/ups/* | grep -v -E "~|stats|set" >> $T

 # Journal
 echo -e "\n        ########### nut-journal ###########" >> $T
 nut-journal >> $T

 # Remove password from report
 L=`grep password $T | tr -d " \t\n\r"`
 if [[ "$L" =~ ^.*=(.+)$ ]]
 then PASS="${BASH_REMATCH[1]}"
      sed "s/$PASS/*********/" < $T > $R
 else # Could not find a password
      cat $T > $R
 fi

 # Explain file hosting
 echo "I have created file \"$R\" with a summary of your NUT configuration."
 echo "Passwords have been removed.  To submit this report to the NUT mailing"
 echo "list, upload the file to a web server if you have access to one, or to"
 echo "a free file hoster such as filehosting.org, and post the URL they give"
 echo "you together with your symptoms in the mailing list."
 echo "To avoid any possible spam, you should use a throw-away e-mail address"
 echo "when uploading to the file hoster.  See for example myTrashMaili.com" 
 rm $T; 
 exit

7 — Automatic daemon start

You will want the NUT daemon to start automatically every time the box starts. To start the daemon automatically:

8 — Running the daemon

8.1 — Check permissions

Check that the permissions and owners of the key configuration files are as shown in Table 1. Do this carefully and thoroughly. Wrong permissions and ownership are a common source of problems with NUT.

For example in 13.2: Check, and correct if needed, the ownership of the binaries:

 pinta:~ # ls -alF /usr/sbin/ups*
 -rwxr-xr-x 1 root root 64984 Oct 15  2014 /usr/sbin/upsd*
 -rwxr-xr-x 1 root root 48584 Oct 15  2014 /usr/sbin/upsmon*
 -rwxr-xr-x 1 root root 31536 Oct 15  2014 /usr/sbin/upssched*
 -rwxr--r-- 1 rpc daemon 2926 Mar 31  2013 /usr/sbin/upssched-cmd*
 pinta:~ # chown upsd:daemon /usr/sbin/ups*
 pinta:~ # chmod 744 /usr/sbin/ups*
 pinta:~ # ls -alF /usr/sbin/ups*
 -rwxr--r-- 1 upsd daemon 64984 Oct 15  2014 /usr/sbin/upsd*
 -rwxr--r-- 1 upsd daemon 48584 Oct 15  2014 /usr/sbin/upsmon*
 -rwxr--r-- 1 upsd daemon 31536 Oct 15  2014 /usr/sbin/upssched*
 -rwxr--r-- 1 upsd daemon  2926 Mar 31  2013 /usr/sbin/upssched-cmd*

8.2 — Restart your box

Experience shows that detection of the USB interface to an Eaton/MGE Ellipse UPS is a delicate matter, and best done during the initial power-on sequence. Note: This problem is limited to the Eaton/MGE Ellipse series devices with combined USB/serial ports also known as USBS ports (RJ-45). It is not a problem with other MGE/Eaton devices.

8.3 — Check USB connection

Check with command lsusb that the UPS is detected:

  Bus 003 Device 002: ID 0463:ffff MGE UPS Systems UPS

8.4 — Try starting the daemon

8.4.1 — openSUSE 12.1 and earlier

Try starting the daemon with the command rcupsd start . In openSUSE distributions 12.1 and earlier you see the result directly:

 sandrane:~ # rcupsd status
 Checking for service NUT UPS server       unused
 Checking for service NUT UPS monitor      unused

 sandrane:~ # rcupsd start
 Starting NUT UPS drivers                  done
 Starting NUT UPS server                   done
 Starting NUT UPS monitor                  done

 sandrane:~ # rcupsd status
 Checking for service NUT UPS server       running
 Checking for service NUT UPS monitor      running

and the following entries appear in /var/log/messages

 Dec 29 01:05:00 sandrane usbhid-ups[5510]: Startup successful
 Dec 29 01:05:00 sandrane upsd[5513]: listening on 127.0.0.1 port 3493
 Dec 29 01:05:00 sandrane upsd[5513]: listening on ::1 port 3493
 Dec 29 01:05:00 sandrane upsd[5513]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Dec 29 01:05:00 sandrane upsd[5514]: Startup successful
 Dec 29 01:05:00 sandrane upsmon[5517]: Startup successful
 Dec 29 01:05:00 sandrane upsd[5514]: User upsmaster@::1 logged into UPS [Eaton]

with command ps aux | grep ups showing:

 upsd ... Ss 13:19 0:00 /usr/lib/ups/driver/usbhid-ups -a Eaton
 upsd ... Ss 13:19 0:00 /usr/sbin/upsd -u upsd
 root ... Ss 13:19 0:00 /usr/sbin/upsmon
 upsd ... S  13:19 0:00 /usr/sbin/upsmon

8.4.2 — openSUSE 12.2 through 13.1

Try starting the daemon with the command rcupsd start

 sandrane:~ # rcupsd start
 redirecting to systemctl

The phrase redirecting to systemctl is SuSE-speak for If you want to see the output, you will have to use command rcupsd status

 sandrane:~ # rcupsd status
 upsd.service - LSB: UPS monitoring software (remote/local)
	  Loaded: loaded (/etc/init.d/upsd)
	  Active: active (running) since Sun, 23 Sep 2012 10:37:43 +0200; 22s ago
	 Process: 2815 ExecStop=/etc/init.d/upsd stop (code=exited, status=0/SUCCESS)
	 Process: 4900 ExecStart=/etc/init.d/upsd start (code=exited, status=0/SUCCESS)
	  CGroup: name=systemd:/system/upsd.service
		  ├ 4918 /usr/lib/ups/driver/usbhid-ups -a Eaton
		  ├ 4922 /usr/sbin/upsd -u upsd
		  ├ 4925 /usr/sbin/upsmon
		  └ 4926 /usr/sbin/upsmon

 Sep 23 10:37:43 sandrane usbhid-ups[4918]: Startup successful
 Sep 23 10:37:43 sandrane upsd[4921]: listening on 127.0.0.1 port 3493
 Sep 23 10:37:43 sandrane upsd[4921]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Sep 23 10:37:43 sandrane upsd[4922]: Startup successful
 Sep 23 10:37:43 sandrane upsd[4900]: Starting NUT UPS server ..done
 Sep 23 10:37:43 sandrane upsmon[4925]: Startup successful
 Sep 23 10:37:43 sandrane upsd[4922]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
 Sep 23 10:37:43 sandrane upsd[4900]: Starting NUT UPS monitor ..done

8.4.3 — openSUSE 13.2

NUT is started automatically by systemd. Check that it is running:

 pinta:~ # ps aux | grep ups
 upsd      1753  ...  Ss   Oct06   0:15 /usr/lib/ups/driver/usbhid-ups -a Eaton
 upsd      1755  ...  Ss   Oct06   0:03 /usr/sbin/upsd
 root      1757  ...  Ss   Oct06   0:00 /usr/sbin/upsmon
 upsd      1758  ...  S    Oct06   0:03 /usr/sbin/upsmon

Note the two instances of upsmon, one as user root, the other as user upsd. You can also check the status of the systemd service units as shown in chapters nut-server, nut-monitor and nut-delayed-ups-shutdown. The command nut-journal should show the status of the current boot:

         Current boot
 Oct 06 22:52:22 pinta upsdrvctl[1530]: Using subdriver: MGE HID 1.32
 Oct 06 22:52:22 pinta upsdrvctl[1530]: Network UPS Tools - Generic HID driver 0.38 (2.7.1)
 Oct 06 22:52:22 pinta upsdrvctl[1530]: USB communication driver 0.32
 Oct 06 22:52:23 pinta upsd[1754]: listening on 127.0.0.1 port 3493
 Oct 06 22:52:23 pinta upsd[1754]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:52:23 pinta upsd[1755]: Startup successful
 Oct 06 22:52:23 pinta upsmon[1757]: Startup successful
 Oct 06 22:52:23 pinta upsd[1755]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:52:23 pinta upsd[1755]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
 Oct 06 22:52:23 pinta hosts.allow[1762]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:52:23 pinta upsd[1755]: warning: /etc/hosts.allow, line 84: Unable to handle client address: localhost
 Oct 06 22:52:23 pinta hosts.allow[1764]: upsd@127.0.0.1 (host localhost/pinta) accepts access to upsd from upsmaster@localhost
 Oct 06 22:52:23 pinta upsdrvctl[1530]: Network UPS Tools - UPS driver controller 2.7.1
 Oct 06 22:52:23 pinta upsd[1754]: fopen /var/lib/ups/upsd.pid: No such file or directory
 Oct 06 22:52:23 pinta upsd[1754]: listening on 127.0.0.1 port 3493
 Oct 06 22:52:23 pinta upsd[1754]: Connected to UPS [Eaton]: usbhid-ups-Eaton
 Oct 06 22:52:23 pinta upsmon[1756]: fopen /var/run/upsmon.pid: No such file or directory
 Oct 06 22:52:23 pinta upsmon[1756]: UPS: Eaton@localhost (master) (power value 1)
 Oct 06 22:52:23 pinta upsmon[1756]: Using power down flag file /etc/killpower

8.5 — UPS details

The command upsc -L should show Eaton: Eaton Ellipse ECO 1600, and the command upsc Eaton will give full details of the UPS:

 battery.charge: 100
 battery.charge.low: 20
 battery.runtime: 3000
 battery.type: PbAc
 device.mfr: EATON
 device.model: Ellipse ECO 1600
 device.serial: 000000000
 device.type: ups
 driver.name: usbhid-ups
 driver.parameter.offdelay: 60
 driver.parameter.ondelay: 70
 driver.parameter.pollfreq: 30
 driver.parameter.pollinterval: 2
 driver.parameter.port: auto
 driver.parameter.vendorid: 0463
 ...
 ups.delay.shutdown: 60
 ups.delay.start: 70
 ups.firmware: 01
 ups.load: 9
 ups.mfr: EATON
 ups.model: Ellipse ECO 1600
 ups.power.nominal: 1600
 ups.productid: ffff
 ups.serial: 000000000
 ups.status: OL CHRG
 ups.timer.shutdown: 0
 ups.timer.start: 0
 ups.vendorid: 0463

8.6 — Check the UPS unit shutdown systemd service

If you are using a systemd service unit to shutdown the UPS unit, check that systemd's final target calls for the UPS delayed shutdown:

 rprice@maria:~> ls -lF /etc/systemd/system/final.target.wants/
 lrwxrwxrwx 1 root root 48 Aug 12 12:31 nut-delayed-ups-shutdown.service -> /etc/systemd/system/nut-delayed-ups-shutdown.service

If you do not see the link, then you have not enabled the unit. See chapter nut-delayed-ups-shutdown.

8.7 — Pull the wall plug

Pull the power plug from the wall socket for just 30 seconds. Since I use LXDE rather than KDE I get the following messages on an lxterminal. KDE may have a more sophisticated presentation.

                                                                               
 Broadcast message from upsd@pinta (somewhere) (Fri Oct  9 10:53:35 2015):      
 UPS Eaton@localhost: On battery +++ Onduleur sur batterie                      
                                                                               
 Broadcast message from upsd@pinta (somewhere) (Fri Oct  9 10:53:41 2015):      
 Running on battery, OB DISCHRG 100% - possible shutdown in 2 minutes - save you
 r work! +++ Sur batterie - arret possible en 2 minutes - sauvez votre travail! 
                                                                               
 Broadcast message from upsd@pinta (somewhere) (Fri Oct  9 10:54:10 2015):      
 UPS Eaton@localhost: On line power +++ Onduleur sur secteur                    
                                                                               
 Broadcast message from upsd@pinta (somewhere) (Fri Oct  9 10:54:10 2015):      
 Power back, OL CHRG 99% - shutdown cancelled. +++ Secteur de retour - arret aba
 ndonne.                                                                        

Pre-13.2 : To see a trace of the work done by upssched and the script upssched-cmd, you must look at file /var/log/messages.

13.2 : To see a trace of the work done by upssched and the script upssched-cmd, use command nut-journal:

 pinta:~ # nut-journal
 ...
 Oct 09 10:53:35 pinta upsmon[1758]: UPS Eaton@localhost: On battery +++ Onduleur sur batterie
 Oct 09 10:53:35 pinta upssched[12058]: Timer daemon started
 Oct 09 10:53:35 pinta upssched[12058]: New timer: two-minute-warning-timer (5 seconds)
 Oct 09 10:53:35 pinta upssched[12058]: New timer: one-minute-warning-timer (65 seconds)
 Oct 09 10:53:35 pinta upssched[12058]: New timer: shutdown-timer (125 seconds)
 Oct 09 10:53:40 pinta upssched[12058]: Event: two-minute-warning-timer
 Oct 09 10:53:40 pinta upssched-cmd[12060]: Calling upssched-cmd two-minute-warning-timer
 Oct 09 10:53:41 pinta upssched-cmd[12063]: Two minute warning timeout reached, OB DISCHRG 100%
 Oct 09 10:54:10 pinta upsmon[1758]: UPS Eaton@localhost: On line power +++ Onduleur sur secteur
 Oct 09 10:54:10 pinta upssched[12058]: Cancelling timer: one-minute-warning-timer
 Oct 09 10:54:10 pinta upssched[12058]: Cancelling timer: shutdown-timer
 Oct 09 10:54:10 pinta upssched[12069]: Executing command: ups-back-on-line
 Oct 09 10:54:10 pinta upssched-cmd[12071]: Calling upssched-cmd ups-back-on-line
 Oct 09 10:54:10 pinta upssched-cmd[12074]: ups_back-on-line: removing timers, OL CHRG 99%
 Oct 09 10:54:10 pinta upssched-cmd[12078]: UPS back on-line, timers removed, OL CHRG 99%
 Oct 09 10:54:23 pinta upssched[12058]: Timer queue empty, exiting

8.8 — Full test

For a full test, pull the power plug from the wall socket. You should see

  1. UPS takes over the power supply to the box and begins beeping.
  2. On Battery warning on screen
  3. 2 minute warning on screen
  4. 1 minute warning on screen
  5. Shutdown message on screen
  6. System shutdown begins
  7. System shutdown complete, UPS still beeping
  8. UPS shutdown, beeping stops.

Push the power plug back into the wall socket, and you should see a complete system restart. See nut-journal for a trace of NUT activity during the shutdown.

9 — IPv4 and IPv6

NUT as packaged in openSUSE 11.3 and since is sensitive to the operation of IPv4 and IPv6. These are both turned on by default in the openSUSE distribution. What happens if I turn IPv6 off? First some background from Arjen de Korte:

A couple of releases ago we decided to no longer listen on all interfaces, but instead only on the loopback interface. This in order to not automatically expose the upsd service on systems that are connected to the internet (which is a security risk if you don't protect the communication through SSL). In order to allow the least amount of surprises for people that are upgrading their systems, we decided to listen to both the IPv4 and IPv6 loopback addresses if IPv6 support is detected at compilation time. In most of the cases, there is really no benefit to switch off IPv6 and in the rare cases there is, there is an option that can be passed to the upsd server to override this default.

This means that if you turn off IPv6, you need to adjust your NUT configuration to take this into account. See upsd.conf and man 5 upsd.conf.

Notes:

  1. This sensitivity to IPv6 operation appeared in openSUSE 11.3. It was not present in release 11.2.
  2. In openSUSE, NUT is compiled with both IPv4 and IPv6 enabled. You could force it to listen on a specific interface by appending -4 (IPv4) or -6 (IPv6) to the call of the daemon upsd. This isn't in the man page for upsd, but will be in the list of options that are displayed when you type upsd -h. However it is much simpler to specify the sockets upsd should listen to with the LISTEN directive in upsd.conf. This will then override the built in defaults.

10 — Setting the low limit on battery charge

You may wish to change the battery low value on your UPS. To see the current value use the command

 pinta:~ # upsc <myups> battery.charge.low
 20

To change the value to say 36 use the command

 pinta:~ # upsrw -s battery.charge.low=36 -u <userid> -p <pass> <myups>

where

and if all goes well you will see the acknowledgement at the bottom of the output of nut-journal, or in /var/log/messages on a pre-13.2 system.

 Oct 29 22:02:34 pinta upsd[1739]: Set variable: upsmaster@127.0.0.1 set battery.charge.low on Eaton to 36

The new value can also be checked using

 pinta:~ # upsc <myups> battery.charge.low
 36

11 — What went wrong?

A few notes on personal experiences.

  1. Permissions and ownership : Check them again, carefully. If you have copied the files from the directory /etc/ups of another installation, the owners and permissions may not have been preserved. For example the userid of user upsd may change from installation to installation.
  2. rcupsd doesn't start NUT : If you install NUT, set it up according to these instructions, and then try to start NUT with the command rcupsd start it may well fail silently. Remember that you were advised to restart your box before starting NUT. Now is the time to do so. Further evidence of UPS non-detection would be given by the command /usr/lib/ups/driver/upsdrvctl start
  3. Login on UPS failed : If you see this message in your log:
     Jan 5 03:40:59 cyan upsmon [9847]: Login on UPS [Eaton@localhost] failed - got [ERR ACCESS-DENIED]

    then maybe your file /etc/hosts.allow does not allow protocol upsd from 127.0.0.1 or [::1]. See hosts.allow, and man tcpd, man -S5 hosts_access and man -S5 hosts_options for a detailed description of hosts.allow and hosts.deny.

  4. Data stale : If the command upsc Eaton produces the result "Error: Data stale", try restarting the ups daemon with the command rcupsd restart. This symptom may be accompanied by an unusually high system load reported by xload on an otherwise idle machine, and a broadcast message such as
     Broadcast Message from upsd@glacon2 (somewhere) at 22:55 ...
     UPS Eaton@localhost is unavailable 

    Note: This is typical for usbhid-ups driver and the MGE/Eaton Ellipse series with NUT versions before 2.4.2. It has to do with a reply from the UPS that was misunderstood by the driver, occasionally resulting in a storm of reconnects. This effect is limited to the MGE/Eaton Ellipse series, other MGE/Eaton devices are not affected by this problem.

  5. UPS not available every 5 minutes After 52 days of uninterrupted service, I started getting the following message every 5 minutes:
     Broadcast Message from upsd@glacon2 (somewhere) at 19:10 ...
     UPS Eaton@localhost: Not available +++ Onduleur indisponible

    I suspect that this is also a peculiarity of the MGE/Eaton Ellipse series with the usbhid-ups driver. Somehow they become synchronised in their inability to connect. The fix is to restart the UPS daemon with the command rcupsd restart. This de-synchronises the driver and the UPS.

  6. Cannot find upsd or nut in Yast -> System services : This is a 13.1 specific problem due to an incomplete systemd setup. See chapter 7 — Automatic daemon start for instructions.

  7. Cannot start NUT UPS server : The command rcupsd restart reports
     Starting NUT UPS drivers ....done
     Starting NUT UPS server startproc:  exit status of parent of /usr/sbin/upsd: 1
                                         ....failed

    File /var/log/messages tails with

     Nov  7 09:53:57 glacon usbhid-ups[4974]: Startup successful
     Nov  7 09:53:57 glacon upsd[4977]: listening on 127.0.0.1 port 3493
     Nov  7 09:53:57 glacon upsd[4977]: not listening on ::1 port 3493
     Nov  7 09:53:59 glacon usbhid-ups[4974]: Signal 15: exiting

    This can happen if you turn IPv6 off, but forget to change upsd.conf. See configuration file upsd.conf for the required modification, then run the command rcupsd restart.

    Alternatively, you can turn IPv6 on again: YaST => Network Devices => Network Settings => Global options => IPv6 Protocol Settings and select Enable IPv6 and then re-boot.

  8. No activity by upssched-cmd : You pulled the power cord from the wall to test the new setup, you received the notification:
     Broadcast Message from upsd@glacon2 (somewhere) at 16:34 ...
     UPS Eaton@localhost: On battery +++ Onduleur sur batterie

    but no further messages. Neither nut-journal nor the file /var/log/messages shows any trace of activity by upssched-cmd. The problem is with the permissions of script upssched-cmd:

     glacon2:~ # ls -alF /usr/sbin/upssched-cmd
     -rw-r--r-- 1 upsd daemon 1936 2010-02-28 16:17 /usr/sbin/upssched-cmd

    Once the permissions were changed to conform to table 1

     glacon2:~ # chmod 744 /usr/sbin/upssched-cmd
     glacon2:~ # ls -alF /usr/sbin/upssched-cmd
     -rwxr--r-- 1 upsd daemon 1936 2010-02-28 16:17 /usr/sbin/upssched-cmd*

    the script executes correctly.

  9. No activity by upssched-cmd : As before, you pulled the power cord from the wall to test the new setup, you received the notification:
     Broadcast Message from upsd@glacon2 (somewhere) at 16:34 ...
     UPS Eaton@localhost: On battery +++ Onduleur sur batterie

    but no further messages. Neither nut-journal nor the file /var/log/messages shows any trace of activity by upssched-cmd. The problem is with NOTIFYFLAG entries in upsmon.conf. You need to add the +EXEC option to the cases for which you want action. I have +EXEC set on all the NOTIFYFLAG's.

  10. Still no activity by upssched-cmd : You pulled the power cord from the wall to test the new setup, you received the notification:
     Broadcast Message from upsd@glacon2 (somewhere) at 16:34 ...
     UPS Eaton@localhost: On battery +++ Onduleur sur batterie

    but there was no further activity and no shutdown. The file /var/log/messages shows

     Feb 19 11:15:26 sandrane upsmon[3435]: UPS Eaton@localhost: On battery +++ Onduleur sur batterie
     Feb 19 11:15:33 sandrane upssched[4720]: Failed to connect to parent and failed to create parent: No such file or directory

    The problem may be that in file upssched.conf you specified

     PIPEFN /var/lib/ups/upssched/upssched.pipe
     LOCKFN /var/lib/ups/upssched/upssched.lock

    but there is no directory /var/lib/ups/upssched. PIPEFN and LOCKFN are now in directory /var/lib/ups/. You should have specified

     PIPEFN /var/lib/ups/upssched.pipe
     LOCKFN /var/lib/ups/upssched.lock

    If you examine directory /var/lib/ups/ you should see:

    sandrane:~ # ls -alF /var/lib/ups
    total 20
    drwx------  3 upsd daemon 4096 19 févr. 11:53 ./
    drwxr-xr-x 44 root root   4096 19 févr. 10:47 ../
    -rw-r--r--  1 upsd daemon    5 19 févr. 11:10 upsd.pid
    srw-rw----  1 upsd daemon    0 19 févr. 11:10 usbhid-ups-Eaton=
    -rw-r--r--  1 upsd daemon    5 19 févr. 11:10 usbhid-ups-Eaton.pid
  11. No connection to UPS : The command upsc -L reports Error: Connection failure: Connection refused and the log /var/log/messages is filling up with a
     cyan upsmon[4340]: UPS [Eaton@localhost]: connect failed: 
                        Connection failure: Connection refused

    every 5 seconds. Has the UPS been stolen? No, it's still there. The command lsusb shows

     Bus 002 Device 002: ID 0463:ffff MGE UPS Systems UPS

    Is the upsd daemon which sits between the UPS drivers and the monitoring programs still operational? The command ps aux | grep upsd shows no activity. upsd is dead. I tried restarting the daemon with the command rcupsd restart:

     cyan:~ # rcupsd restart
     Shutting down NUT UPS monitor                         done
     Shutting down NUT UPS server                          done
     Shutting down NUT UPS drivers                         done
     Starting NUT UPS drivers                              done
     Starting NUT UPS server startproc:  exit status of parent of /usr/sbin/upsd: 1

    This error appeared when the server executing the NUT daemon was repositioned in the local network. It was taken from it's place as a router receiving traffic directly from the Internet to a subsidiary position below another router. The IP number changed as did the FQDN (fully qualified domain name), however no changes were made to the server configuration. The problem was solved by returning the server to it's previous rôle as a router, and the problem was not investigated any further.

  12. No restart when wall power returns : The system has shut down correctly following a wall power failure. However the UPS unit goes on beeping. When wall power returns, the server does not restart.

    This is a problem since openSUSE 12.2: see the chapter Setup and the Race for a fix.

  13. Too short a delay between server shutdown and UPS shutdown : This delay is built into the UPS unit, either fixed or as a variable. To change the delay you need to change the value of a variable in the UPS unit.

    If you wish to know which UPS values are variables which can be changed, use command upsrw ups-name where ups-name must match the name of the UPS defined in ups.conf. Our example has ups-name Eaton.

     cyan:~ # upsrw Eaton
     ...
     [ups.delay.shutdown]
     Interval to wait after shutdown with delay command (seconds)
     Type: STRING
     Value: 30
    
     [ups.delay.start]
     Interval to wait before (re)starting the load (seconds)
     Type: STRING
     Value: 40

    You can also check the values of the variables using the commands

     cyan:~ # upsc Eaton ups.delay.shutdown
     30
     cyan:~ # upsc Eaton ups.delay.start
     40

    To change the values of the variables, see options offdelay and ondelay in chapter ups.conf.

    In general, if you want to know which commands the UPS unit will accept, use command upscmd -l ups-name.

    These commands assume that you have a running NUT installation.

  14. Unexpected UPS discharge: I replaced the three batteries in my UPS and some days later discovered that my server had crashed. The reason was that the batteries were completely discharged, and one of the frequent short power outages had occured. The UPS was unable to support the server for even a few seconds, certainly not for enough time to allow an orderly shutdown.

    To remedy the situation, I added a "low battery" shutdown procedure to my setup. This involved making changes to upssched.conf where I added the new timer definition

     # Defective UPS runs down on its own for no reason!
     # Give warning and turn off box in 30 seconds
     AT LOWBATT * START-TIMER low-battery-timer 5
     AT LOWBATT * START-TIMER shutdown-timer 65

    I also updated upssched-cmd to include the additional timer handling

      # Defective UPS runs down on its own for no reason.
      # On low battery, warn about quick system shutdown.
      low-battery-timer)
              logger -i -t upssched-cmd "Low battery warning, $CHMSG"
              echo $MSG4 | wall
      ;;

    Note that when timer shutdown-timer runs out, the existing upssched-cmd configuration will shut down the server.

  15. On battery warning, but no shutdown : The command rcupsd status reports
     Checking for service NUT UPS server ..running
     Checking for service NUT UPS monitor ..running
     upsd.service - LSB: UPS monitoring software (remote/local)
        Loaded: loaded (/etc/init.d/upsd)
        Active: active (running) since Mon 2013-12-02 21:45:17 CET; 6min ago
       Process: 11265 ExecStop=/etc/init.d/upsd stop (code=exited, status=0/SUCCESS)
       Process: 11311 ExecStart=/etc/init.d/upsd start (code=exited, status=0/SUCCESS)
        CGroup: /system.slice/upsd.service
                ├─11329 /usr/lib/ups/driver/usbhid-ups -a Eaton
                ├─11333 /usr/sbin/upsd -u upsd
                ├─11336 /usr/sbin/upsmon
                └─11337 /usr/sbin/upsmon
    
     Dec 02 21:45:17 pinta upsd[11332]: listening on 127.0.0.1 port 3493
     Dec 02 21:45:17 pinta upsd[11332]: Connected to UPS [Eaton]: usbhid-ups-Eaton
     Dec 02 21:45:17 pinta upsd[11333]: Startup successful
     Dec 02 21:45:17 pinta upsd[11311]: Starting NUT UPS server ..done
     Dec 02 21:45:17 pinta upsmon[11336]: Startup successful
     Dec 02 21:45:17 pinta upsd[11333]: User upsmaster@127.0.0.1 logged into UPS [Eaton]
     Dec 02 21:45:17 pinta upsd[11311]: Starting NUT UPS monitor ..done
     Dec 02 21:45:17 pinta systemd[1]: Started LSB: UPS monitoring software (remote/local).

    in which one sees clearly the two upsmon processes 11336 and 11337. Command ps aux | grep ups reports

    upsd     11329  0.0  0.0  13232   644 ?        Ss   21:45   0:00 /usr/lib/ups/driver/usbhid-ups -a Eaton
    upsd     11333  0.0  0.0  19848  1080 ?        Ss   21:45   0:00 /usr/sbin/upsd -u upsd
    root     11336  0.0  0.0  19388   656 ?        Ss   21:45   0:00 /usr/sbin/upsmon
    upsd     11337  0.0  0.0  19812   816 ?        S    21:45   0:00 /usr/sbin/upsmon

    All this looks perfect, so what's gone wrong?

    Yet again there are file permission and ownership problems with this new installation. The ownerships and permissions are currently

     pinta:~ # ls -alF /usr/sbin/ups*
     -rwxr-xr-- 1 root root   64904 Sep 28 11:05 /usr/sbin/upsd*
     -rwxr-xr-- 1 root root   44416 Sep 28 11:05 /usr/sbin/upsmon*
     -rwxr-xr-- 1 root root   31464 Sep 28 11:05 /usr/sbin/upssched*
     -rwxr--r-- 1 upsd daemon  2926 Mar 31  2013 /usr/sbin/upssched-cmd*

    This does not correspond to those given in Table 1. Correct the error:

     pinta:~ # chmod 744 /usr/sbin/ups*
     pinta:~ # chown upsd:daemon /usr/sbin/ups*
     pinta:~ # ls -alF /usr/sbin/ups*
     -rwxr--r-- 1 upsd daemon 64904 Sep 28 11:05 /usr/sbin/upsd*
     -rwxr--r-- 1 upsd daemon 44416 Sep 28 11:05 /usr/sbin/upsmon*
     -rwxr--r-- 1 upsd daemon 31464 Sep 28 11:05 /usr/sbin/upssched*
     -rwxr--r-- 1 upsd daemon  2926 Mar 31  2013 /usr/sbin/upssched-cmd*

    Restart upsd with command systemctl restart upsd.service and the problem is solved.

12 — Acknowledgements and Copyright

As one of the many who have used the work of the NUT project as part of their system setup, I would like to express my gratitude and my appreciation for the software that the NUT project has made available to system administrators.

Much of the code and text in this page is derived from work by the NUT project, MGE/Eaton and contributions by Charles Lepple, Arjen de Korte, Arnaud Quette and others in the Nut-upsuser mailing list.

The <HTML> element of this page with its content is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The <HTML> element is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this page. If not, see <http://www.gnu.org/licenses/>.

To republish this page, you will need to place a valid DOCTYPE declaration before the <HTML> element.


© Copyright 2005-2016 Roger Price < roger at rogerprice dot org >
In order to facilitate access from all browsers, now and in the future, these pages conform to the International Standard ISO/IEC 15445 and the corresponding W3C Recommendations. Last change: lun. août 1 12:15:44 CEST 2016
Valid HTML 4.01! Valid CSS! Level A conformance icon,            W3C-WAI Web Content Accessibility Guidelines 1.0 Valid ISO 15445!
Fight spam! Click here!
http://rogerprice.org/NUT.html