[Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade

Jim Klimov jimklimov+nut at gmail.com
Fri Dec 2 22:24:56 GMT 2022


FWIW, this and other recent discussions led to a few PRs and investigative
issues about paths and PIDs and signals - so here's some reading for your
enjoyment:
* https://github.com/networkupstools/nut/pull/1724
* https://github.com/networkupstools/nut/issues/1721
* https://github.com/networkupstools/nut/issues/1728
* https://github.com/networkupstools/nut/issues/1727
* https://github.com/networkupstools/nut/pull/1719
* https://github.com/networkupstools/nut/issues/1712
* https://github.com/networkupstools/nut/issues/1714

Jim

On Fri, Dec 2, 2022, 17:19 Bill Gee <bgee at campercaver.net> wrote:

> Oops, sorry about missing your test two.  I did not read it all the way
> through.
>
> That test is done, and nut-server starts successfully.  Upsc will give
> back information about the device.  I did have to run a daemon-reload.
> It does complain about not finding the PID file.
>
> =================================
> [root at mythtv ups]# cat
> /etc/systemd/system/nut-server.service.d/environ.conf
> [Service]
> Environment=NUT_STATEPATH=/run/nut
> [root at mythtv ups]# cat
> /etc/systemd/system/nut-driver at .service.d/environ.conf
> [Service]
> Environment=NUT_STATEPATH=/run/nut
>
> [root at mythtv ups]# systemctl --full --no-pager status nut-server
> ● nut-server.service - Network UPS Tools - power devices information server
>       Loaded: loaded (/usr/lib/systemd/system/nut-server.service;
> enabled; preset: disabled)
>      Drop-In: /etc/systemd/system/nut-server.service.d
>               └─environ.conf
>       Active: active (running) since Fri 2022-12-02 10:11:18 CST; 9s ago
>     Main PID: 12675 (upsd)
>        Tasks: 1 (limit: 9482)
>       Memory: 732.0K
>          CPU: 5ms
>       CGroup: /system.slice/nut-server.service
>               └─12675 /usr/sbin/upsd -F
>
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: fopen
> /run/nut/upsd.pid: No such file or directory
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Could not find
> PID file '/run/nut/upsd.pid' to see if previous upsd instance is already
> running!
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: listening on ::1
> port 3493
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: listening on
> 127.0.0.1 port 3493
> Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: listening on ::1 port
> 3493
> Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: listening on 127.0.0.1
> port 3493
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Connected to UPS
> [cyberpower]: usbhid-ups-cyberpower
> Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: Connected to UPS
> [cyberpower]: usbhid-ups-cyberpower
> Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: Running as foreground
> process, not saving a PID file
> Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Running as
> foreground process, not saving a PID file
> =============================
>
> ===============
> Bill Gee
>
> On 12/2/22 06:24, Simon Wilson via Nut-upsuser wrote:
> > Hi Bill,
> >
> > OK your test 1 and 2 line up with my ask for test 1 :)
> >
> > Have another read of the Test 2 ask please if you can:
> >
> >>> 2. Second test:- copy the edited
> >>> /etc/systemd/system/nut-driver at .service.d/environ.conf to
> >>> /etc/systemd/system/nut-server.service.d/environ.conf. So you should
> >>> at that point have both locations with a file saying
> >>>   [Service]
> >>>   Environment=NUT_STATEPATH=/run/nut
> >>> Then comment out STATEPATH line (back to default) in upsd.conf and
> >>> restart nut-server - does it still start, and does it still pop a
> >>> "Could not find PID file '/var/run/upsd.pid'" message? That tests
> >>> whether the drop-in file is a better, more consistent fix for now
> >>> (until the packages are resolved). Calling the nut-server process
> >>> with that variable set for upsd *even before it reads upsd.conf* may
> >>> remove the first error 'Could not find PID file '/var/run/upsd.pid''
> >
> > Your test 3 and 4 are not quite what is needed, unless you did copy the
> > environ.conf file into /etc/systemd/system/nut-server.service.d/ but
> > didn't say so?
> >
> > Could you please copy your nut-driver's environ.conf file to
> > /etc/systemd/system/nut-server.service.d/ THEN comment out the STATEPATH
> > line and see if nut-server starts.
> >
> > Why am I asking this>
> > At the moment you are using one fix to resolve the driver (an
> > environ.conf file) and a different fix to get nut-server going
> > (STATEPATH). Trying to see if one fix (the environ.conf file fix) will
> > resolve both driver and server, and in doing so also get rid of the
> > error message 'Could not find PID file '/var/run/upsd.pid''.
> >
> > Simon
> >
> > ----- Message from Bill Gee <bgee at campercaver.net> ---------
> >     Date: Fri, 2 Dec 2022 06:07:20 -0600
> >     From: Bill Gee <bgee at campercaver.net>
> > Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
> >       To: nut-upsuser at alioth-lists.debian.net
> >
> >
> >> Test 1 - I moved the environ.conf file to /tmp.  I ran systemctl
> >> daemon-reload, then restarted nut-driver at cyberpower.service.  Results:
> >>
> >> =====================================
> >> [root at mythtv nut-driver at .service.d]# systemctl restart
> >> nut-driver at cyberpower.service
> >> Job for nut-driver at cyberpower.service failed because the control
> >> process exited with error code.
> >> See "systemctl status nut-driver at cyberpower.service" and "journalctl
> >> -xeu nut-driver at cyberpower.service" for details.
> >> [root at mythtv nut-driver at .service.d]# systemctl --full --no-pager
> >> status nut-driver at cyberpower.service
> >> ● nut-driver at cyberpower.service - Network UPS Tools - device driver
> >> for NUT device 'cyberpower'
> >>      Loaded: loaded (/usr/lib/systemd/system/nut-driver at .service;
> >> enabled; preset: disabled)
> >>     Drop-In: /etc/systemd/system/nut-driver at cyberpower.service.d
> >>              └─nut-driver-enumerator-generated-checksum.conf,
> >> nut-driver-enumerator-generated.conf
> >>      Active: activating (auto-restart) (Result: exit-code) since Fri
> >> 2022-12-02 05:54:03 CST; 2s ago
> >>     Process: 10732 ExecStartPre=/usr/bin/systemd-tmpfiles --create
> >> /usr/lib/tmpfiles.d/nut-client.conf (code=exited, status=0/SUCCESS)
> >>     Process: 10733 ExecStart=/bin/sh -c
> >> NUTDEV="`/usr/libexec/nut-driver-enumerator.sh
> >> --get-device-for-service cyberpower`" && [ -n "$NUTDEV" ] || { echo
> >> "FATAL: Could not find a NUT device section for service unit
> >> cyberpower" >&2 ; exit 1 ; } ; /usr/sbin/upsdrvctl start "$NUTDEV"
> >> (code=exited, status=1/FAILURE)
> >>         CPU: 80ms
> >> =========================================
> >>
> >> It seems that the nut device driver requires environ.conf to be present.
> >>
> >> Test 2 - I moved environ.conf back to the correct place.  I edited the
> >> file to use "Environment=NUT_STATEPATH=/run/nut".  I did a
> >> daemon-reload then started the nut-driver.  It worked - no errors.
> >>
> >> Test 3 - I modified /etc/ups/upsd.conf to comment out the STATEPATH
> >> line.  I restarted nut-server.service.  It failed.
> >>
> >> ================================
> >> [root at mythtv ups]# systemctl --full --no-pager status nut-server
> >> ● nut-server.service - Network UPS Tools - power devices information
> >> server
> >>      Loaded: loaded (/usr/lib/systemd/system/nut-server.service;
> >> enabled; preset: disabled)
> >>      Active: active (running) since Fri 2022-12-02 06:00:54 CST; 13s ago
> >>    Main PID: 11452 (upsd)
> >>       Tasks: 1 (limit: 9482)
> >>      Memory: 728.0K
> >>         CPU: 5ms
> >>      CGroup: /system.slice/nut-server.service
> >>              └─11452 /usr/sbin/upsd -F
> >>
> >> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on
> >> ::1 port 3493
> >> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on
> >> 127.0.0.1 port 3493
> >> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on ::1
> >> port 3493
> >> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on
> >> 127.0.0.1 port 3493
> >> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: /var/run is
> >> world readable
> >> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: /var/run is world
> >> readable
> >> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Can't connect to UPS
> >> [cyberpower] (usbhid-ups-cyberpower): No such file or directory
> >> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Can't connect
> >> to UPS [cyberpower] (usbhid-ups-cyberpower): No such file or directory
> >> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Running as
> >> foreground process, not saving a PID file
> >> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Running as
> >> foreground process, not saving a PID file
> >> ===================================
> >>
> >> Test 4 - I uncommented the STATEPATH line in upsd.conf.  It points to
> >> /run/nut.  I restarted nut-server.  Success.
> >>
> >>
> >> ===============
> >> Bill Gee
> >>
> >> On 12/1/22 18:35, Simon Wilson via Nut-upsuser wrote:
> >>> Resending as original was too big for list acceptance.
> >>>
> >>> Hi Bill,
> >>>
> >>> /etc/systemd/system/nut-driver at .service.d/environ.conf sets the
> >>> nut-driver service's environment variable, such that it sees a
> >>> workable NUT_STATEPATH of /var/run/nut when upsdrvctl is run by the
> >>> service, regardless of what is set in upsd.conf, and explains why the
> >>> driver worked yesterday but upsd didn't.
> >>>
> >>> Tests which may be interesting:
> >>>
> >>> 1. First test:- move nut-driver's environ.conf file to somewhere else
> >>> temporarily; leave upsd.conf STATEPATH uncommented saying /run/nut;
> >>> restart nut-driver at cyberpower.service; and see if it runs. This tests
> >>> to see if it *needs* the drop-in service file *or* will work with
> >>> only STATEPATH explicitly set in upsd.conf to /run/nut.  If this
> >>> prevents the driver from working, put the environ.conf file back (but
> >>> edit it, it should say /run/nut, not /var/run/nut)
> >>>
> >>> 2. Second test:- copy the edited
> >>> /etc/systemd/system/nut-driver at .service.d/environ.conf to
> >>> /etc/systemd/system/nut-server.service.d/environ.conf. So you should
> >>> at that point have both locations with a file saying
> >>>   [Service]
> >>>   Environment=NUT_STATEPATH=/run/nut
> >>> Then comment out STATEPATH line (back to default) in upsd.conf and
> >>> restart nut-server - does it still start, and does it still pop a
> >>> "Could not find PID file '/var/run/upsd.pid'" message? That tests
> >>> whether the drop-in file is a better, more consistent fix for now
> >>> (until the packages are resolved). Calling the nut-server process
> >>> with that variable set for upsd *even before it reads upsd.conf* may
> >>> remove the first error 'Could not find PID file '/var/run/upsd.pid''
> >>>
> >>> And definitely document any changes you make to your setup as
> >>> subsequent package releases will likely change all of this :)
> >>>
> >>> Couple more comments inline below.
> >>>
> >>> Simon
> >>>
> >>>
> >>> ----- Message from Bill Gee <bgee at campercaver.net> ---------
> >>>    Date: Thu, 1 Dec 2022 16:49:14 -0600
> >>>    From: Bill Gee <bgee at campercaver.net>
> >>> Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
> >>>      To: nut-upsuser at alioth-lists.debian.net
> >>>
> >>>> Checking now - There is a file called
> >>>> /etc/systemd/system/nut-driver at .service.d/environ.conf.  Its
> >>>> contents are
> >>>>
> >>>> ==========================
> >>>> [root at mythtv nut-driver at .service.d]# ll
> >>>> total 8
> >>>> -rw-r--r-- 1 root root 49 Nov 29 18:14 environ.conf
> >>>> -rw-r--r-- 1 root root 81 Nov 30 18:58
> >>>> nut-driver-enumerator-generated-checksum.conf
> >>>>
> >>>> [root at mythtv nut-driver at .service.d]# cat environ.conf
> >>>> [Service]
> >>
> >> [snip]
> >>
> >> _______________________________________________
> >> Nut-upsuser mailing list
> >> Nut-upsuser at alioth-lists.debian.net
> >> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
> >
> >
> > ----- End message from Bill Gee <bgee at campercaver.net> -----
> >
> >
> >
>
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20221202/fbd9aaea/attachment-0001.htm>


More information about the Nut-upsuser mailing list