[Nut-upsuser] NUT with openSUSE 13.2

Roger Price roger at rogerprice.org
Fri Oct 9 15:07:15 UTC 2015


I have been looking closely at using NUT with openSUSE 13.2.  Here is
a quick summary.

1. Like the alien plant in the Quatermass Experiment, systemd is
reaching into every corner of the distribution.  New systemd service
units exist in /usr/lib/systemd/system:

  Power devices information server, nut-server.service, starts upsd
  Power devices monitor and shutdown controller, nut-monitor.service, starts upsmon
  Power device driver controller, nut-driver.service, starts upsdrvctl

The first two need to be enabled using Yast => System => Services
Manager for them to start automatically when the box is turned on.

nut-driver.service needs fixing. Replace

  ExecStart=/upsdrvctl start
  ExecStop=/upsdrvctl stop

with

  ExecStart=/usr/lib/ups/driver/upsdrvctl start
  ExecStop=/usr/lib/ups/driver/upsdrvctl stop

2. On my box, openSUSE hangs for 30 seconds trying to shut down a WiFi
connection. This increases the system shutdown time, so I increased
offdelay and ondelay in ups.conf by 30 seconds.

3. openSUSE have declared TCP-wrappers to be "abandon-ware", but the
libwrap package is installed and used by a half dozen programs.  In
release 13.2 openSUSE compile NUT with the wrappers, but other
programs, such as openssh are now stripped of their wrappers.

4. All logging goes to systemd's journalctl - there is no more
/var/log/messages.  Since journalctl provides extraction by service
unit rather than by tag, I wrote a Bash script to extract the lines
generated by NUT activity.

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

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

  # 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

5. openSUSE supply a script to shutdown the UPS.  The script
"nutshutdown" sits in systemd drop-in directory
/usr/lib/systemd/system-shutdown/ and automatically executes

  /usr/sbin/upsmon -K >/dev/null 2>&1 && /usr/lib/ups/driver/upsdrvctl shutdown

There is no trace in the log of the action of this script.

I personally prefer a traceable service unit for shutting down the
UPS, so I replaced the openSUSE script with
nut-delayed-ups-shutdown.sevice enabled by Yast => System => Services
Manager.  For details of this and a more complete discussion of NUT
with openSUSE 13.2, see http://rogerprice.org/NUT.html

Roger



More information about the Nut-upsuser mailing list