Bug in nut-upsmon v. 2.8.1-r1

Hi all, I've just installed an OpenWrt snapshot (r26235-0d74b2a1e5 from 2024-05-08T00:54:32) on my Belkin RT1800, coming from OpenWrt 23.05.3, and I've noticed a small but fatal bug in nut-upsmon, it spawns multiple processes as the path to check for an existing process has a missing directory, /run/upsmon.pid vs. /var/run/upsmon.pid, see the below logs from the snapshot vs. OpenWrt 23.05.3:

OpenWrt snapshot r26235-0d74b2a1e5 from 2024-05-08T00:54:32 - nut-upsmon v. 2.8.1-r1 (upsmon spawns multiple processes):

Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.000005	fopen /run/upsmon.pid: No such file or directory
Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.000371	Could not find PID file to see if previous upsmon instance is already running!
Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.000989	Using power down flag file /var/run/killpower
Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.001812	UPS: qnapups@localhost (primary) (power value 1)
Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.002083	[D1] debug level is '1'
Wed May  8 02:55:21 2024 daemon.err upsmon[7155]:    0.006400	writepid: fopen /run/upsmon.pid: No such file or directory

OpenWrt 23.05.3 - nut-upsmon v. 2.8.0-3 (upsmon is working fine):

Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.000000	fopen /var/run/upsmon.pid: No such file or directory
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.000204	Could not find PID file to see if previous upsmon instance is already running!
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.000829	Using power down flag file /var/run/killpower
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.001554	UPS: qnapups@localhost (primary) (power value 1)
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.001890	[D1] debug level is '1'
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.002058	[D1] debug level is '1'
Wed May  8 11:25:35 2024 daemon.err upsmon[7159]:    0.007170	[D1] Saving PID 7199 into /var/run/upsmon.pid

I've opened an issue on GitHub: https://github.com/openwrt/packages/issues/24106

I can tell you exactly why this is happening:

writepid: fopen /run/upsmon.pid: No such file or directory

/run directory location does not exist and the newer version of nut is now wanting to put it’s PID file there, instead of /var/run like it used to.

To work around this for now I created a symlink /run -> /var/run.

Also, as far as I know there is no knob or control in nut to force a specific PID location either.

1 Like

Thanks for your reply. Yep, it's a typo on the path and AFAICT it's hard coded in the package. Good thinking to work it around with a symlink.

I'm already back on OpenWrt 23.05.3, I took a peek at the snapshot yesterday to check if it fixed another problem I'm having but it didn't.

I hadn't revisited this weird nut pid problem since I did my own symlink workaround months ago.

I did some digging, check this out. It looks like there's something in the nut source code Makefile/configure that actually hard compiles that path into the nut binaries based on the host used to compile the packages?? lol WTH

1 Like

Good find. I guess the next version will come with a complimentary symlink :wink: