nut icon indicating copy to clipboard operation
nut copied to clipboard

upsmon -K error

Open cschuber opened this issue 2 years ago • 1 comments

One of my users is reporting this:

upsmon -K

Network UPS Tools upsmon 2.8.0 Fatal error: A previous upsmon instance is already running! Either stop the previous instance first, or use the 'reload' command.

This happens whether POWERDOWNFLAG file exists or not. It looks like like the program checks the pid file before the marker file. I think that it shouldn't worry about the pid file with -K.

Also, reported elsewhere: https://github.com/opnsense/plugins/issues/3013 Testing it msyelf I get the same result. cwfw# upsmon -K Network UPS Tools upsmon 2.8.0.1 Fatal error: A previous upsmon instance is already running! Either stop the previous instance first, or use the 'reload' command. cwfw# echo $? 1 cwfw#

The man page says,

   -K
       Test for the shutdown flag. If it exists and contains the magic
       string from upsmon, then upsmon will exit with EXIT_SUCCESS. Any
       other condition will make upsmon exit with EXIT_FAILURE.

       You can test for a successful exit from upsmon -K in your shutdown
       scripts to know when to call upsdrvctl(8) to shut down the UPS.

Is there something we don't understand or have we discovered a bug?

cschuber avatar Oct 14 '22 13:10 cschuber

Looks like an edge case: I see no harm in checking for the flag while a daemon is running (so arguably a bug to fix), but the practical use-case is late in OS shutdown (to power off local UPSes) when daemons are likely killed off already.

jimklimov avatar Oct 14 '22 16:10 jimklimov