#962800 nut: NUT and systemd interacting poorly

Package:
nut-client
Source:
nut
Description:
network UPS tools - clients
Submitter:
Christi Scarborough
Date:
2023-09-26 12:36:04 UTC
Severity:
normal
#962800#5
Date:
2020-06-14 10:45:21 UTC
From:
To:
Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?

Installing of nut-client on the host system - I believe the problem is also present in a full NUT installation though.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

apt install nut-client
Basic configuration of NUT to act as a client to a UPS on a different machine on the network.

   * What was the outcome of this action?

Errors present in syslog as follows:

Jun 14 11:29:51 yaga systemd[1]: /lib/systemd/system/nut-monitor.service:6: PIDFile= references path below legacy directory /var/run/, updating /var/run/nut/upsmon.pid → /run/nut/upsmon.pid; please update the unit file accordingly.
Jun 14 11:32:46 yaga systemd[1]: Starting Network UPS Tools - power device monitor and shutdown controller...
Jun 14 11:32:46 yaga upsmon[34188]: fopen /var/run/nut/upsmon.pid: No such file or directory
Jun 14 11:32:46 yaga upsmon[34188]: UPS: <upsid> (slave) (power value 1)
Jun 14 11:32:46 yaga upsmon[34188]: Using power down flag file /etc/killpower
Jun 14 11:32:46 yaga systemd[1]: nut-monitor.service: Can't open PID file /run/nut/upsmon.pid (yet?) after start: No such file or directory
Jun 14 11:32:46 yaga upsmon[34195]: Startup successful
Jun 14 11:32:46 yaga systemd[1]: Started Network UPS Tools - power device monitor and shutdown controller.
Jun 14 11:32:46 yaga upsmon[34196]: Init SSL without certificate database

Although the app is working, both errors (the first and 6th lines above are of concern, as I am uncertain whether they will cause unpredictable behaviour.

Thank you,

Christi

*** End of the template - remove these template lines ***

#962800#12
Date:
2021-12-22 02:45:24 UTC
From:
To:
Christi Scarborough wrote:

I see this also, on a Debian 11 host with nut-client installed.
The nut server is on a different host.
I tried a couple of variations of this, but it didn't help:

    # /etc/systemd/system/nut-monitor.service.d/override.conf

    # Trying to fix these warnings:
    #    nut-monitor.service: Can't open PID file /run/nut/upsmon.pid (yet?) after start: Operation not permitted
    #    nut-monitor.service: Supervising process 1287240 which is not our child. We'll most likely not notice when it exits.
    [Service]
    RuntimeDirectory=nut
    # Because /run/nut is shared by several nut units,
    # do not erase it when THIS one ends.
    # This might not be necessary, but
    # I cannot easily tell, because
    # I only run nut-monitor on this host!
    RuntimeDirectoryPreserve=true
    # Sigh, because upsmon starts as root then drops privs,
    # it still fails to write to root:root /run/nut?
    # Start upsmon as root:nut and make /run/nut root:nut.
    # Maybe that will be enough to make thus STFU?
    Group=nut

#962800#17
Date:
2021-12-22 03:03:01 UTC
From:
To:
This is working to remove both warnings.
I'm 99% sure the real problem is that upsmon is trying to do things that are now systemd's job.
You can see the "kill" log even there which suggests upsmon remains derp.

    # Trying to fix these warnings:
    #    nut-monitor.service: Can't open PID file /run/nut/upsmon.pid (yet?) after start: Operation not permitted
    #    nut-monitor.service: Supervising process 1287240 which is not our child. We'll most likely not notice when it exits.
    [Service]
    RuntimeDirectory=nut
    # Because /run/nut is shared by several nut units,
    # do not erase it when THIS one ends.
    # This might not be necessary, but
    # I cannot easily tell, because
    # I only run nut-monitor on this host!
    RuntimeDirectoryPreserve=true
    # Sigh, because upsmon starts as root then drops privs,
    # it still fails to write to root:root /run/nut?
    # Start upsmon as root:nut and make /run/nut root:nut.
    # Maybe that will be enough to make thus STFU?
    Group=nut
    # <damjan> twb just remove PIDFile=
    PIDFile=


cyber@light:~$ systemctl status nut-monitor
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
     Loaded: loaded (/lib/systemd/system/nut-monitor.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/nut-monitor.service.d
             └─override.conf
     Active: active (running) since Wed 2021-12-22 13:56:11 AEDT; 6min ago
    Process: 1303859 ExecStart=/sbin/upsmon (code=exited, status=0/SUCCESS)
   Main PID: 1303860 (upsmon)
      Tasks: 2 (limit: 4653)
     Memory: 896.0K
        CPU: 17ms
     CGroup: /system.slice/nut-monitor.service
             ├─1303860 /lib/nut/upsmon
             └─1303861 /lib/nut/upsmon

Dec 22 13:56:11 light systemd[1]: Starting Network UPS Tools - power device monitor and shutdown controller...
Dec 22 13:56:11 light upsmon[1303859]: kill: No such process
Dec 22 13:56:11 light upsmon[1303859]: UPS: upset@omega.cyber.com.au (slave) (power value 1)
Dec 22 13:56:11 light upsmon[1303859]: Using power down flag file /etc/killpower
Dec 22 13:56:11 light upsmon[1303860]: Startup successful
Dec 22 13:56:11 light systemd[1]: Started Network UPS Tools - power device monitor and shutdown controller.
Dec 22 13:56:11 light upsmon[1303861]: Init SSL without certificate database

#962800#22
Date:
2023-09-26 12:32:32 UTC
From:
To:
Setting up nut-client on a RPi 3B+ and a RPi 4B.

admin@nut-clientns1080:~ $ upsc nut-clientns1080@localhost
Error: Connection failure: Connection refused
admin@nut-clientns1080:~ $ upsc nut-server550@192.168.xxx.xxx
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10

##############################

#######  snipped for brevity #######

##############################

ups.model: Back-UPS ES 550
ups.productid: 0002
ups.serial: 3B0743X46110
ups.status: OL
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d
admin@nut-clientns1080:~ $ sudo systemctl status nut-client
● nut-monitor.service - Network UPS Tools - power device monitor and
shutdown controller
     Loaded: loaded (/lib/systemd/system/nut-monitor.service; enabled;
vendor preset: enabled)
     Active: active (running) since Mon 2023-09-25 08:25:22 EDT; 23h ago
    Process: 899 ExecStart=/sbin/upsmon (code=exited, status=0/SUCCESS)
   Main PID: 901 (upsmon)
      Tasks: 2 (limit: 1599)
        CPU: 9.925s
     CGroup: /system.slice/nut-monitor.service
             ├─900 /lib/nut/upsmon
             └─901 /lib/nut/upsmon

Sep 25 08:25:22 nut-clientns1080 systemd[1]: Starting Network UPS Tools -
power device monitor and shutdown controller...
Sep 25 08:25:22 nut-clientns1080 upsmon[899]: fopen /run/nut/upsmon.pid: No
such file or directory
Sep 25 08:25:22 nut-clientns1080 upsmon[899]: UPS:
nut-server550@192.168.xxx.xxx (slave) (power value 1)
Sep 25 08:25:22 nut-clientns1080 upsmon[899]: Using power down flag file
/etc/killpower
Sep 25 08:25:22 nut-clientns1080 upsmon[900]: Startup successful
Sep 25 08:25:22 nut-clientns1080 systemd[1]: nut-monitor.service: Can't
open PID file /run/nut/upsmon.pid (yet?) after start: Operation not
permitted
Sep 25 08:25:22 nut-clientns1080 systemd[1]: nut-monitor.service:
Supervising process 901 which is not our child. We'll most likely not
notice when it exits.
Sep 25 08:25:22 nut-clientns1080 upsmon[901]: Init SSL without certificate
database
Sep 25 08:25:22 nut-clientns1080 systemd[1]: Started Network UPS Tools -
power device monitor and shutdown controller.
Sep 25 08:25:22 nut-clientns1080 upsmon[901]: Login on UPS
[nut-server550@192.168.xxx.xxx] failed - got [ERR ACCESS-DENIED]


Output of /var/log/syslog

Sep 26 07:51:41 nut-clientns1080 upsmon[901]: Signal 15: exiting

Sep 26 07:51:41 nut-clientns1080 systemd[1]: Stopping Network UPS Tools -
power device monitor and shutdown controller...

Sep 26 07:51:41 nut-clientns1080 systemd[1]: nut-monitor.service: Succeeded.

Sep 26 07:51:41 nut-clientns1080 systemd[1]: Stopped Network UPS Tools -
power device monitor and shutdown controller.

Sep 26 07:51:41 nut-clientns1080 systemd[1]: nut-monitor.service: Consumed
10.030s CPU time.

Sep 26 07:51:41 nut-clientns1080 systemd[1]: Starting Network UPS Tools -
power device monitor and shutdown controller...

Sep 26 07:51:41 nut-clientns1080 upsmon[12471]: fopen /run/nut/upsmon.pid:
No such file or directory

Sep 26 07:51:41 nut-clientns1080 upsmon[12471]: UPS:
nut-server550@192.168.xxx.xxx (slave) (power value 1)

Sep 26 07:51:41 nut-clientns1080 upsmon[12471]: Using power down flag file
/etc/killpower

Sep 26 07:51:41 nut-clientns1080 upsmon[12473]: Startup successful

Sep 26 07:51:41 nut-clientns1080 systemd[1]: nut-monitor.service: Can't
open PID file /run/nut/upsmon.pid (yet?) after start: Operation not
permitted

Sep 26 07:51:41 nut-clientns1080 systemd[1]: nut-monitor.service:
Supervising process 12474 which is not our child. We'll most likely not
notice when it exits.

Sep 26 07:51:41 nut-clientns1080 systemd[1]: Started Network UPS Tools -
power device monitor and shutdown controller.

Sep 26 07:51:41 nut-clientns1080 upsmon[12474]: Init SSL without
certificate database

Sep 26 07:51:41 nut-clientns1080 upsmon[12474]: Login on UPS
[nut-server550@192.168.xxx.xxx] failed - got [ERR ACCESS-DENIED]


Hardware in use:
RPi 4B configuration:

admin@nut-clientns1080:~ $ pinout
Revision           : b03112
SoC                : BCM2711
RAM                : 2GB
Storage            : MicroSD

RPi 3B+ configuration:

admin@nut-clientes550:~ $ pinout
Revision           : a020d3
SoC                : BCM2837
RAM                : 1GB
Storage            : MicroSD

Both RPi's are running Raspbian 11 Lite 64-bit OS with current version of
NUT.

admin@nut-client550:~ $ sudo apt list nut
Listing... Done
nut/oldstable,oldstable,now 2.7.4-13 all [installed]


While searching web for a solution I found Debian bug #962800.

Is there a workaround available?