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@mythtv ups]# cat /etc/systemd/system/nut-server.service.d/environ.conf
[Service]
Environment=NUT_STATEPATH=/run/nut
[root@mythtv ups]# cat /etc/systemd/system/[email protected]/environ.conf
[Service]
Environment=NUT_STATEPATH=/run/nut

[root@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/[email protected]/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 <[email protected]> ---------
    Date: Fri, 2 Dec 2022 06:07:20 -0600
    From: Bill Gee <[email protected]>
Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
      To: [email protected]


Test 1 - I moved the environ.conf file to /tmp.  I ran systemctl daemon-reload, then restarted [email protected].  Results:

=====================================
[root@mythtv [email protected]]# systemctl restart [email protected] Job for [email protected] failed because the control process exited with error code. See "systemctl status [email protected]" and "journalctl -xeu [email protected]" for details. [root@mythtv [email protected]]# systemctl --full --no-pager status [email protected] [email protected] - Network UPS Tools - device driver for NUT device 'cyberpower'      Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/[email protected]
             └─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@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/[email protected]/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 [email protected]; 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/[email protected]/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 <[email protected]> ---------
   Date: Thu, 1 Dec 2022 16:49:14 -0600
   From: Bill Gee <[email protected]>
Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
     To: [email protected]

Checking now - There is a file called /etc/systemd/system/[email protected]/environ.conf.  Its contents are

==========================
[root@mythtv [email protected]]# 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@mythtv [email protected]]# cat environ.conf
[Service]

[snip]

_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser


----- End message from Bill Gee <[email protected]> -----




_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to