Simon Wilson
2022-Dec-02 00:35 UTC
[Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
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] > Environment=NUT_STATEPATH=/var/run/nut > > =========================> > Which explains, I think, much of the problem.? I do not remember > putting that file in place.? However, it is dated 29 Nov, just a > couple of days ago, so it was probably me who did it.It's not a default file, so yes it was you - this was a suggestion I made earlier in the week (although I suggested it should say /run/nut not /var/run/nut), and with it there explains why the driver works before you uncommented STATEPATH in upsd.conf.> > Should I delete the file?? Or change it to use /run/nut?See comments on tests at the top of this email.> > And that raises another interesting question:? Since /var/run and > /run are effectively the same thing, why does /run work and /var/run > not work?What makes you think one works and the other does not? They *are* functionally the same thing (excepting a harmless warning message about using /var).> > ==============> Bill Gee > > On 12/1/22 16:38, Simon Wilson via Nut-upsuser wrote: >> Working nut-driver, working nut-server. That's a lot further than >> you were on Tuesday. >> >> It's a little odd that nut-driver worked without STATEPATH being >> uncommented in upsd.conf but nut-server needed the change. >> @Jim, without digging into source, any reason why that would be the case? >> @Bill, you didn't end up doing an 'environ.conf'-style drop-in file >> at '/etc/systemd/system/nut-driver at .service.d/' did you (as that >> would explain the difference between the two services)? >> >> You will need to enable nut.target to have things start on boot, >> and reboot to make sure everything starts OK. >> >> Simon >> >> ----- Message from Bill Gee <bgee at campercaver.net> --------- >> ? ?Date: Thu, 1 Dec 2022 10:43:04 -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 >> >>> My email client (Thunderbird) does not truncate, but it does >>> wrap.? The truncations come from the way systemctl runs its output >>> through a pager. When I copy-paste from the bash session, it >>> truncates at the right edge of the window.? ?I need to use the >>> --full and --no-pager options to get the full text, which will be >>> wrapped as needed. >>> >>> Here is the output from upsd -DD: >>> >>> ==================================>>> [root at mythtv ~]# upsd -DD >>> Network UPS Tools upsd 2.8.0 >>> ? 0.000000? ? ?fopen /var/run/upsd.pid: No such file or directory >>> ? 0.000030? ? ?Could not find PID file '/var/run/upsd.pid' to see >>> if previous upsd instance is already running! >>> >>> ? 0.000250? ? ?[D1] debug level is '2' >>> ? 0.000335? ? ?listening on ::1 port 3493 >>> ? 0.000375? ? ?listening on 127.0.0.1 port 3493 >>> ? 0.001417? ? ?/var/run is world readable >>> ? 0.001557? ? ?Can't connect to UPS [cyberpower] >>> (usbhid-ups-cyberpower): No such file or directory >>> ? 0.002315? ? ?Running as foreground process, not saving a PID file >>> ? 0.002337? ? ?[D1] mainloop: UPS [cyberpower] is not currently connected >>> ? 0.002377? ? ?[D1] mainloop: UPS [cyberpower] is now connected as FD -1 >>> ? 0.002399? ? ?[D2] mainloop: polling 2 filedescriptors >>> ? 2.003794? ? ?[D2] mainloop: no data available >>> ? 2.003842? ? ?[D1] mainloop: UPS [cyberpower] is not currently connected >>> ? 2.003897? ? ?[D1] mainloop: UPS [cyberpower] is now connected as FD -1 >>> ? 2.003917? ? ?[D2] mainloop: polling 2 filedescriptors >>> ? 4.005963? ? ?[D2] mainloop: no data available >>> ? 4.006009? ? ?[D1] mainloop: UPS [cyberpower] is not currently connected >>> ? 4.006054? ? ?[D1] mainloop: UPS [cyberpower] is now connected as FD -1 >>> ? 4.006073? ? ?[D2] mainloop: polling 2 filedescriptors >>> ? 6.008122? ? ?[D2] mainloop: no data available >>> =============================>>> >>> Just for grins, I edited /etc/ups/upsd.conf to uncomment the >>> STATEPATH line.? I set it to /run/nut.? When I ran upsd -DD again, >>> it was still looking at /var/run.? However!? It successfully >>> connected to the cyberpower device.? Upsc returns good information. >>> >>> ================================>>> [root at mythtv ups]# upsd -DD >>> Network UPS Tools upsd 2.8.0 >>> ? 0.000000? ? ?fopen /var/run/upsd.pid: No such file or directory >>> ? 0.000037? ? ?Could not find PID file '/var/run/upsd.pid' to see >>> if previous upsd instance is already running! >>> >>> ? 0.000271? ? ?[D1] debug level is '2' >>> ? 0.000357? ? ?listening on ::1 port 3493 >>> ? 0.000395? ? ?listening on 127.0.0.1 port 3493 >>> ? 0.001550? ? ?Connected to UPS [cyberpower]: usbhid-ups-cyberpower >>> ? 0.002323? ? ?Running as foreground process, not saving a PID file >>> ? 0.002347? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 0.002423? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 0.002493? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 0.002570? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 0.002648? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 0.002701? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 2.004311? ? ?[D2] mainloop: no data available >>> ? 2.004352? ? ?[D2] mainloop: polling 3 filedescriptors >>> ? 4.006061? ? ?[D2] mainloop: no data available >>> >>> [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; >>> disabled; preset: disabled) >>> ? ? Active: active (running) since Thu 2022-12-01 10:35:01 CST; 18s ago >>> ? Main PID: 3445 (upsd) >>> ? ? ?Tasks: 1 (limit: 9482) >>> ? ? Memory: 732.0K >>> ? ? ? ?CPU: 4ms >>> ? ? CGroup: /system.slice/nut-server.service >>> ? ? ? ? ? ? ??3445 /usr/sbin/upsd -F >>> >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: fopen >>> /var/run/upsd.pid: No such file or directory >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: Could not >>> find PID file '/var/run/upsd.pid' to see if previous upsd instance >>> is already running! >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: listening >>> on ::1 port 3493 >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: listening >>> on 127.0.0.1 port 3493 >>> Dec 01 10:35:01 mythtv.billgee.local upsd[3445]: listening on ::1 port 3493 >>> Dec 01 10:35:01 mythtv.billgee.local upsd[3445]: listening on >>> 127.0.0.1 port 3493 >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: Connected >>> to UPS [cyberpower]: usbhid-ups-cyberpower >>> Dec 01 10:35:01 mythtv.billgee.local upsd[3445]: Connected to UPS >>> [cyberpower]: usbhid-ups-cyberpower >>> Dec 01 10:35:01 mythtv.billgee.local upsd[3445]: Running as >>> foreground process, not saving a PID file >>> Dec 01 10:35:01 mythtv.billgee.local nut-server[3445]: Running as >>> foreground process, not saving a PID file >>> >>> [root at mythtv ups]# upsc cyberpower at localhost >>> battery.charge: 100 >>> battery.charge.low: 10 >>> battery.charge.warning: 20 >>> battery.mfr.date: CPS >>> battery.runtime: 2100 >>> battery.runtime.low: 300 >>> battery.type: PbAcid >>> battery.voltage: 13.3 >>> battery.voltage.nominal: 12 >>> device.mfr: CPS >>> device.model: UPS CP1000AVRLCD >>> device.type: ups >>> driver.name: usbhid-ups >>> [-- snip --] >>> >>> ==============>>> Bill Gee >>> >>> On 12/1/22 06:41, Simon Wilson via Nut-upsuser wrote: >>>> Hi Bill, well at least you now have a fully operating, >>>> starts-on-reboot driver - so that is progress. One thing we need >>>> to know which I asked but you've not answered: >>>> "Did you need to add the environment drop-in file? At which step >>>> did it work?" The answer to that may change next step. >>>> >>>> nut-server *should* just work if there is a driver available and running. >>>> >>>> OK, run: >>>> >>>> ?systemctl disable nut-server (stop it trying to run automatically) >>>> ?upsd -DD >>>> >>>> And then Ctrl-C to stop it once you have got output to screen >>>> with startup messages. >>>> >>>> Then copy back here the output from upsd -DD, preferably without >>>> truncating lines which your mail client seems to do :( >>>> >>>> I'm pretty sure that nut-server is using /var/run as its >>>> STATEPATH. Can you also include your upsd.conf, minus commented >>>> lines. >>>> >>>> Simon. >>>> >>>> ----- Message from Bill Gee <bgee at campercaver.net> --------- >>>> ?? Date: Thu, 1 Dec 2022 06:14:10 -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 >>>> >>>>> Hi Simon - >>>>> >>>>> I modified /usr/lib/tmpfiles.d/nut-client to use /run instead of >>>>> /var/run.? I checked the startup status of the nut services. >>>>> >>>>> ================>>>>> [root at mythtv ~]# systemctl list-unit-files | grep -i nut >>>>> nut-driver-enumerator.path? enabled???????? disabled >>>>> nut-driver-enumerator.service? enabled???????? disabled >>>>> nut-driver at .service? indirect??????? disabled >>>>> nut-monitor.service? disabled??????? disabled >>>>> nut-server.service? enabled???????? disabled >>>>> nut-driver.target? disabled??????? disabled >>>>> nut.target? disabled??????? disabled >>>>> =========================>>>>> >>>>> I did a shutdown/reboot on the system.? The usbhid driver loaded >>>>> without errors and did not complain about /var/run.? /run/nut >>>>> exists and contains the expected two files. >>>>> >>>>> nut-server also started since it is set to "enabled", but failed >>>>> to connect to the driver.? It complains about "no such file or >>>>> directory". What file is it looking for?? I ran journalctl on it >>>>> but got nothing more than what systemctl status reports. >>>>> >>>>> ==========================>>>>> [root at mythtv ~]# systemctl status nut-driver at cyberpower >>>>> ? 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 .service.d >>>>> ???????????? ??environ.conf >>>>> ???????????? /etc/systemd/system/nut-driver at cyberpower.service.d >>>>> ???????????? ??nut-driver-enumerator-generated-checksum.conf, >>>>> nut-driver-enumerator-generated.conf >>>>> ???? Active: active (running) since Thu 2022-12-01 05:56:04 CST; 9min ago >>>>> ??? Process: 712 ExecStartPre=/usr/bin/systemd-tmpfiles --create >>>>> /usr/lib/tmpfiles.d/nut-client.conf (code=exited, stat> >>>>> ??? Process: 719 ExecStart=/bin/sh -c >>>>> NUTDEV="`/usr/libexec/nut-driver-enumerator.sh >>>>> --get-device-for-service cyberpowe> >>>>> ?? Main PID: 791 (usbhid-ups) >>>>> ????? Tasks: 1 (limit: 9482) >>>>> ???? Memory: 2.9M >>>>> ??????? CPU: 113ms >>>>> ???? CGroup: >>>>> /system.slice/system-nut\x2ddriver.slice/nut-driver at cyberpower.service >>>>> ???????????? ??791 /usr/sbin/usbhid-ups -a cyberpower >>>>> >>>>> Dec 01 05:56:04 mythtv.billgee.local nut-driver at cyberpower[787]: >>>>> Using subdriver: CyberPower HID 0.6 >>>>> Dec 01 05:56:04 mythtv.billgee.local nut-driver at cyberpower[787]: >>>>> Network UPS Tools - Generic HID driver 0.47 (2.8.0) >>>>> Dec 01 05:56:04 mythtv.billgee.local nut-driver at cyberpower[787]: >>>>> USB communication driver (libusb 1.0) 0.43 >>>>> Dec 01 05:56:04 mythtv.billgee.local nut-driver at cyberpower[787]: >>>>> cps_adjust_battery_scale: battery readings will be sca> >>>>> Dec 01 05:56:04 mythtv.billgee.local nut-driver at cyberpower[719]: >>>>> Network UPS Tools - UPS driver controller 2.8.0 >>>>> Dec 01 05:56:04 mythtv.billgee.local usbhid-ups[791]: Startup successful >>>>> >>>>> [root at mythtv ~]# systemctl 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 Thu 2022-12-01 05:56:07 CST; 9min ago >>>>> ?? Main PID: 809 (upsd) >>>>> ????? Tasks: 1 (limit: 9482) >>>>> ???? Memory: 1000.0K >>>>> ??????? CPU: 15ms >>>>> ???? CGroup: /system.slice/nut-server.service >>>>> ???????????? ??809 /usr/sbin/upsd -F >>>>> >>>>> Dec 01 05:56:08 mythtv.billgee.local upsd[809]: listening on ::1 >>>>> port 3493 >>>>> Dec 01 05:56:08 mythtv.billgee.local upsd[809]: listening on >>>>> 127.0.0.1 port 3493 >>>>> Dec 01 05:56:08 mythtv.billgee.local nut-server[809]: /var/run >>>>> is world readable >>>>> Dec 01 05:56:08 mythtv.billgee.local nut-server[809]: Can't >>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): No suc> >>>>> Dec 01 05:56:08 mythtv.billgee.local upsd[809]: /var/run is >>>>> world readable >>>>> Dec 01 05:56:08 mythtv.billgee.local upsd[809]: Can't connect to >>>>> UPS [cyberpower] (usbhid-ups-cyberpower): No such file> >>>>> Dec 01 05:56:10 mythtv.billgee.local nut-server[809]: Running as >>>>> foreground process, not saving a PID file >>>>> Dec 01 05:56:10 mythtv.billgee.local upsd[809]: Running as >>>>> foreground process, not saving a PID file >>>>> Dec 01 06:01:08 mythtv.billgee.local nut-server[809]: Can't >>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): No suc> >>>>> Dec 01 06:01:08 mythtv.billgee.local upsd[809]: Can't connect to >>>>> UPS [cyberpower] (usbhid-ups-cyberpower): No such file> >>>>> ===============================>>>>> >>>>> ==============>>>>> Bill Gee >>>>> >>>>> On 11/30/22 21:14, Simon Wilson via Nut-upsuser wrote: >>>>>> ----- Message from Bill Gee <bgee at campercaver.net> --------- >>>>>> ?? Date: Wed, 30 Nov 2022 19:26:46 -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 >>>>>> >>>>>>> Hi Simon - >>>>>>> >>>>>>> I ran through the steps you gave below.? To quote >>>>>>> Gilbert&Sullivan ... "Modified Rapture!"? I suppose I should >>>>>>> try a reboot to make sure everything starts properly. >>>>>> >>>>>> Not yet with the reboot. Baby steps... :) you have a driver >>>>>> running from the service file! Celebrations are in order. >>>>>> >>>>>> Did you need to add the environment drop-in file? At which step >>>>>> did it work? >>>>>> >>>>>>> But first, there is a problem with upsc. Also nut-server >>>>>>> complains that it cannot connect to the device. >>>>>> >>>>>> Ok, that's next... your comments are wrong way around :) >>>>>> nut-server not starting is why upsc doesn't give you anything. >>>>>> >>>>>>> /run/nut exists and contains two files. >>>>>>> >>>>>>> Here are some outputs: >>>>>>> >>>>>>> =====================================>>>>>>> [root at mythtv ~]# journalctl -u nut-driver at cyberpower.service -f >>>>>>> Nov 30 19:00:20 mythtv.billgee.local systemd[1]: Starting >>>>>>> nut-driver at cyberpower.service - Network UPS Tools - device >>>>>>> driver for NUT device 'cyberpower'... >>>>>>> Nov 30 19:00:20 mythtv.billgee.local systemd-tmpfiles[28689]: >>>>>>> /usr/lib/tmpfiles.d/nut-client.conf:2: Line references path >>>>>>> below legacy directory /var/run/, updating /var/run/nut ? >>>>>>> /run/nut; please update the tmpfiles.d/ drop-in file >>>>>>> accordingly. >>>>>> >>>>>> That line is the "noise" error I mentioned. Edit >>>>>> /usr/lib/tmpfiles.d/nut-client.conf to read /run/nut, not >>>>>> /var/run/nut >>>>>> >>>>>>> Nov 30 19:00:20 mythtv.billgee.local systemd-tmpfiles[28689]: >>>>>>> /usr/lib/tmpfiles.d/nut-client.conf:3: Line references path >>>>>>> below legacy directory /var/run/, updating /var/run/nut ? >>>>>>> /run/nut; please update the tmpfiles.d/ drop-in file >>>>>>> accordingly. >>>>>> >>>>>> Ditto, although you probably don't need line 3 in the file anyway. >>>>>> >>>>>>> Nov 30 19:00:21 mythtv.billgee.local >>>>>>> nut-driver at cyberpower[28719]: Using subdriver: CyberPower HID >>>>>>> 0.6 >>>>>>> Nov 30 19:00:21 mythtv.billgee.local >>>>>>> nut-driver at cyberpower[28719]: Network UPS Tools - Generic HID >>>>>>> driver 0.47 (2.8.0) >>>>>>> Nov 30 19:00:21 mythtv.billgee.local >>>>>>> nut-driver at cyberpower[28719]: USB communication driver (libusb >>>>>>> 1.0) 0.43 >>>>>>> Nov 30 19:00:21 mythtv.billgee.local >>>>>>> nut-driver at cyberpower[28719]: cps_adjust_battery_scale: >>>>>>> battery readings will be scaled by 2/3 >>>>>>> Nov 30 19:00:21 mythtv.billgee.local usbhid-ups[28769]: >>>>>>> Startup successful >>>>>>> Nov 30 19:00:21 mythtv.billgee.local >>>>>>> nut-driver at cyberpower[28691]: Network UPS Tools - UPS driver >>>>>>> controller 2.8.0 >>>>>>> Nov 30 19:00:21 mythtv.billgee.local systemd[1]: Started >>>>>>> nut-driver at cyberpower.service - Network UPS Tools - device >>>>>>> driver for NUT device 'cyberpower'. >>>>>>> >>>>>>> [root at mythtv ups]# ll /run/nut >>>>>>> total 4 >>>>>>> srw-rw---- 1 nut nut 0 Nov 30 19:00 usbhid-ups-cyberpower >>>>>>> -rw-r--r-- 1 nut nut 6 Nov 30 19:00 usbhid-ups-cyberpower.pid >>>>>>> >>>>>>> [root at mythtv ups]# systemctl --no-pager --full 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 Wed 2022-11-30 19:06:53 >>>>>>> CST; 13min ago >>>>>>> ?? Main PID: 28918 (upsd) >>>>>>> ????? Tasks: 1 (limit: 9482) >>>>>>> ???? Memory: 736.0K >>>>>>> ??????? CPU: 20ms >>>>>>> ???? CGroup: /system.slice/nut-server.service >>>>>>> ???????????? ??28918 /usr/sbin/upsd -F >>>>>>> >>>>>>> Nov 30 19:06:53 mythtv.billgee.local nut-server[28918]: >>>>>>> /var/run is world readable >>>>>>> Nov 30 19:06:53 mythtv.billgee.local upsd[28918]: /var/run is >>>>>>> world readable >>>>>>> Nov 30 19:06:53 mythtv.billgee.local upsd[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> Nov 30 19:06:53 mythtv.billgee.local nut-server[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> Nov 30 19:06:53 mythtv.billgee.local nut-server[28918]: >>>>>>> Running as foreground process, not saving a PID file >>>>>>> Nov 30 19:06:53 mythtv.billgee.local upsd[28918]: Running as >>>>>>> foreground process, not saving a PID file >>>>>>> Nov 30 19:11:53 mythtv.billgee.local nut-server[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> Nov 30 19:11:53 mythtv.billgee.local upsd[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> Nov 30 19:16:53 mythtv.billgee.local nut-server[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> Nov 30 19:16:53 mythtv.billgee.local upsd[28918]: Can't >>>>>>> connect to UPS [cyberpower] (usbhid-ups-cyberpower): >>>>>>> Connection refused >>>>>>> >>>>>>> [root at mythtv ups]# ps ax | grep ups >>>>>>> ??? 768 ???????? Ss???? 0:00 /usr/sbin/cupsd -l >>>>>>> ??? 773 ???????? Ss???? 0:00 sshd: /usr/sbin/sshd -D >>>>>>> [listener] 0 of 10-100 startups >>>>>>> ? 28769 ???????? Ss???? 0:00 /usr/sbin/usbhid-ups -a cyberpower >>>>>>> ? 28918 ???????? Ss???? 0:00 /usr/sbin/upsd -F >>>>>>> ? 28929 pts/1??? S+???? 0:00 grep --color=auto ups >>>>>>> >>>>>>> [root at mythtv ups]# upsc cyberpower at localhost >>>>>>> Error: Driver not connected >>>>>> >>>>>> upsc won't work without nut-server running, so this is expected >>>>>> based on the above failure to start nut-server. >>>>>> >>>>>>> ? >>>>>> >>>>>> So... next. >>>>>> >>>>>> Fix nut-client.conf contents, and make sure that you can start >>>>>> / restart the driver as needed with no errors. Set >>>>>> nut-driver at cyberpower.service to enabled for autostart, so with >>>>>> ONLY the enumerator services and nut-driver at cyberpower.service >>>>>> enabled, you should see something like the following for >>>>>> 'systemctl list-unit-files | grep -i nut': >>>>>> >>>>>> [root at emp80 ups]# systemctl list-unit-files | grep -i nut >>>>>> nut-driver-enumerator.path? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ?? enabled >>>>>> nut-driver-enumerator.service? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ??? enabled >>>>>> nut-driver at .service? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ??? indirect >>>>>> nut-monitor.service? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ??? disabled >>>>>> nut-server.service? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ?? disabled >>>>>> nut-driver.target? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ??? disabled >>>>>> nut.target? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? >>>>>> ? ? ?? disabled >>>>>> >>>>>> Stop any running nut processes, and reboot. On reboot the only >>>>>> thing that should autostart is nut-driver at cyberpower.service >>>>>> (from the 'indirect' call via nut-driver at .service). upsc will >>>>>> still not work. >>>>>> >>>>>> Monitor the driver for a while 'journalctl -u >>>>>> nut-driver at cyberpower.service -f' and make sure it is stable >>>>>> and stays connected - google searches show some flakiness with >>>>>> some cyberpower UPSs. >>>>>> >>>>>> Once you are confident that the driver is reliable, starting OK >>>>>> and staying up then move on to nut-server. >>>>>> >>>>>> I'll check in this evening and we can do some more digging on that. >>>>>> >>>>>> Simon >>>>>> >>>>>>> ==============>>>>>>> Bill Gee >>>>>>> >>>>>>> On 11/30/22 07:21, Simon Wilson via Nut-upsuser wrote: >>>>>>>> Comments inline. >>>>>>>> >>>>>>>> ----- Message from Bill Gee <bgee at campercaver.net> --------- >>>>>>>> ?? Date: Wed, 30 Nov 2022 06:04: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 >>>>>>>> >>>>>>>>> Hi Simon -- >>>>>>>>> >>>>>>>>> Yes, I am pretty sure this is the RedHat packaging problem.? >>>>>>>>> I sure hope they get it squared away.? I have only one >>>>>>>>> system using nut and that is because all my other systems >>>>>>>>> have APC battery backup and run apcupsd. Apcupsd may be old, >>>>>>>>> grey and unmaintained, but it Just Works. >>>>>>>>> >>>>>>>>> You mention that the STATEPATH line in upsd.conf will >>>>>>>>> override other settings.? It does not appear to be the case >>>>>>>>> for me.? The only way I could get the driver to run was by >>>>>>>>> setting NUT_STATEPATH on the command line.? Perhaps that is >>>>>>>>> an issue with the driver and not nut-server? >>>>>>>>> >>>>>>>>> In answer to your questions: >>>>>>>>> >>>>>>>>> 1) /usr/lib/systemd/system/nut-driver at .service exists.? I >>>>>>>>> have made no changes to it so far.? Here are the contents, >>>>>>>>> unfortunately line-wrapped by Thunderbird. >>>>>>>>> >>>>>>>>> ===============================>>>>>>>>> [root at mythtv system]# grep -v '^#' nut-driver at .service >>>>>>>>> [Unit] >>>>>>>>> Description=Network UPS Tools - device driver for %I >>>>>>>>> After=local-fs.target >>>>>>>>> >>>>>>>>> PartOf=nut-driver.target >>>>>>>>> >>>>>>>>> [Service] >>>>>>>>> EnvironmentFile=-/etc/ups/nut.conf >>>>>>>>> SyslogIdentifier=%N >>>>>>>>> ExecStartPre=-/usr/bin/systemd-tmpfiles --create >>>>>>>>> /usr/lib/tmpfiles.d/nut-client.conf >>>>>>>>> ExecStart=/bin/sh -c >>>>>>>>> 'NUTDEV="`/usr/libexec/nut-driver-enumerator.sh >>>>>>>>> --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo >>>>>>>>> "FATAL: Could not find a NUT device section for service unit >>>>>>>>> %i" >&2 ; exit 1 ; } ; /usr/sbin/upsdrvctl start "$NUTDEV"' >>>>>>>>> ExecStop=/bin/sh -c >>>>>>>>> 'NUTDEV="`/usr/libexec/nut-driver-enumerator.sh >>>>>>>>> --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo >>>>>>>>> "FATAL: Could not find a NUT device section for service unit >>>>>>>>> %i" >&2 ; exit 1 ; } ; /usr/sbin/upsdrvctl stop "$NUTDEV"' >>>>>>>>> StartLimitInterval=0 >>>>>>>>> Restart=always >>>>>>>>> RestartSec=15s >>>>>>>>> Type=forking >>>>>>>>> >>>>>>>>> [Install] >>>>>>>>> WantedBy=nut-driver.target >>>>>>>>> ==================================>>>>>>>> >>>>>>>> OK, so that's the same as mine. It's ExecStartPre task is to >>>>>>>> create the pid folder from your answer to the third (unasked) >>>>>>>> question :) which is that outlined in >>>>>>>> /usr/lib/tmpfiles.d/nut-client.conf >>>>>>>> >>>>>>>> You have /var/run/nut 0770 root nut - so systemd should >>>>>>>> ensure that exists. >>>>>>>> >>>>>>>> By the way, having it with "/var/run/nut" will trigger a >>>>>>>> 'noise' error about the "/var" path - change it to just be >>>>>>>> /run/nut in nut-client.conf. >>>>>>>> >>>>>>>> As a test, what happens if you: >>>>>>>> >>>>>>>> - make sure nut.conf has MODE=standalone >>>>>>>> - make sure ALL nut services are stopped, i.e. 'ps -ax | grep >>>>>>>> ups' should give you only the grep process as an answer >>>>>>>> - delete /run/nut folder (it will get re-created automatically) >>>>>>>> - take /etc/ups/upsd.conf back to have commented out >>>>>>>> STATEPATH as distributed in the package >>>>>>>> - run "systemctl enable nut-driver-enumerator.path >>>>>>>> nut-driver-enumerator.service --now" - this will enable and >>>>>>>> start the services that monitor ups.conf for changes and then >>>>>>>> write the actual driver service file; the second one also >>>>>>>> runs early in boot and ensures that the service file exists >>>>>>>> and is correct. >>>>>>>> - run 'nut-scanner -U' and copy its output into ups.conf >>>>>>>> instead of your current definition with name heading >>>>>>>> [cyberpower], save and exit: this will trigger the above >>>>>>>> enumerators to run and re-do the >>>>>>>> nut-driver at cyberpower.service file >>>>>>>> >>>>>>>> Based on an out of the box install, you have at this point >>>>>>>> done enough that the driver should run (*should*!!!!) >>>>>>>> >>>>>>>> - run "journalctl -u nut-driver at cyberpower.service -f" in one >>>>>>>> terminal while you run "systemctl start >>>>>>>> nut-driver at cyberpower.service" in another - what does >>>>>>>> journalctl output? >>>>>>>> >>>>>>>> Assuming it does not start (based on what you have said >>>>>>>> below), show the messages. >>>>>>>> >>>>>>>> If it still does not start as configured above, but you \can/ >>>>>>>> run /usr/sbin/usbhid-ups with your environment variables >>>>>>>> specified like you had done before, and it *does* run, then >>>>>>>> do the following steps to create a systemd drop-in file for >>>>>>>> the variable, but make the steps use /run/nut instead of >>>>>>>> /var/run/nut:? >>>>>>>> https://bugzilla.redhat.com/show_bug.cgi?id=2127269#c8? >>>>>>>> (comment 8, formatted for ease of reading). You want to get >>>>>>>> back to the RH/Fedora default of using /run/nut, not >>>>>>>> /var/state/ups >>>>>>>> >>>>>>>> ? 1. uncomment the "STATEPATH /var/run/nut" as already mentioned >>>>>>>> ? 2. create: /etc/systemd/system/nut-driver at .service.d/environ.conf >>>>>>>> ?? with these two lines: >>>>>>>> >>>>>>>> ??? [Service] >>>>>>>> ??? Environment=NUT_STATEPATH=/var/run/nut >>>>>>>> >>>>>>>> ? 3. and finally do: systemctl daemon-reload >>>>>>>> >>>>>>>> ...then try and run systemctl start >>>>>>>> nut-driver at cyberpower.service again, while monitoring >>>>>>>> journalctl. >>>>>>>> >>>>>>>> If that does not work - then I'm out of ideas at this point lol... :-D >>>>>>>> >>>>>>>> 'set' has nothing BTW on my working system related to nut. >>>>>>>> >>>>>>>>> 2) In /etc/ups/upsd.conf, the original STATEPATH line is >>>>>>>>> >>>>>>>>> STATEPATH /var/run/nut >>>>>>>>> >>>>>>>>> Right now the original line is commented and I added another >>>>>>>>> line to point at /var/state/ups. >>>>>>>>> >>>>>>>>> 3) You only asked two questions, but I sense a third might >>>>>>>>> be important.? Originally the system had >>>>>>>>> /usr/lib/tmpfiles.d/nut-common.conf.? I have modified that >>>>>>>>> file and no longer have the original.? I copied that file to >>>>>>>>> nut-client.conf, and both have the same contents: >>>>>>>>> >>>>>>>>> ======================>>>>>>>>> # State file (e.g. upsd to driver) and pidfile location for NUT: >>>>>>>>> D /var/run/nut 0770 root nut - - >>>>>>>>> X /var/run/nut >>>>>>>>> =======================>>>>>>>>> >>>>>>>>> 4) And one more unasked question!? :-)? When I look at the >>>>>>>>> environment variables on the system, I see this: >>>>>>>>> >>>>>>>>> =======================>>>>>>>>> [root at mythtv tmpfiles.d]# set | grep -i nut >>>>>>>>> _=/etc/ups/nut.conf >>>>>>>>> =======================>>>>>>>>><snip to reduce message size> -- Simon Wilson M: 0400 12 11 16
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]