Skip to content

Conversation

@jimklimov
Copy link
Member

@jimklimov jimklimov commented Jan 23, 2026

Inspired by discussion in #3276

Example outputs from NIT setup (with locally added debug_min - note it applies to both the tool and started driver; another line in the driver's section can override that with a larger or smaller value):

:; NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc NUT_STATEPATH=`pwd`/tests/NIT/tmp/run ./drivers/upsdrvctl stop dummy
Network UPS Tools upsdrvctl - UPS driver controller 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5)
   0.000000     [D1:init] debug level for upsdrvctl is '5'
   0.000045     [D1:init] upsdrvctl commanding one driver (dummy): stop
   0.000052     [D1:stop-dummy] Stopping UPS: dummy
   0.000143     Can't open /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid: No such file or directory
   0.000223     Can't open /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.seq.pid either: No such file or directory
   0.000277     WARNING: ./drivers/upsdrvctl was called directly on a system with systemd support.
    Please consider using 'upsdrvsvcctl' instead, to avoid conflicts with
    nut-driver service instances prepared by 'nut-driver-enumerator'!
   0.000327     [D1:stop-dummy] For more details see https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
   0.000388     [D1:stop-dummy] To silence this warning export NUT_QUIET_INIT_NDE_WARNING with any value
   0.000437     [D1:stop-dummy] upsdrvctl: got some errors with preceding operations, exiting with failure now
   0.000450     [D1:stop-dummy] Completed the job of upsdrvctl tool, cleaning up and exiting now
   0.000456     [D1:stop-dummy] Completed the job of upsdrvctl tool, clean-up finished, exiting now
   0.000497     [D2:stop-dummy] a upsdrvctl sub-process (stop-dummy) is exiting now
:; NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc NUT_STATEPATH=`pwd`/tests/NIT/tmp/run ./drivers/upsdrvctl start dummy
Network UPS Tools upsdrvctl - UPS driver controller 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5)
   0.000000     [D1:init] debug level for upsdrvctl is '5'
   0.000032     [D2:init]
If you're not a NUT core developer, chances are that you're told to enable debugging
to see why a driver isn't working for you. We're sorry for the confusion, but this is
the 'upsdrvctl' wrapper, not the driver you're interested in.

Below you'll find one or more lines starting with 'exec:' followed by an absolute
path to the driver binary and some command line option. This is what the driver
starts and you need to copy and paste that line and append the debug flags to that
line (less the 'exec:' prefix).

Alternately, provide an additional '-d' (lower-case) parameter to 'upsdrvctl' to
pass its current debug level to the launched driver, and '-B' keeps it backgrounded.

   0.000070     [D1:init] upsdrvctl commanding one driver (dummy): start
   0.000083     [D1:start-dummy] Starting UPS: dummy
   0.000115     [D2:start-dummy] 3 remaining attempts
   0.000142     [D2:start-dummy] exec:  /home/jim/nut/drivers/dummy-ups -a dummy
   0.000399     [D1:start-dummy-child] forkexec: calling execv(/home/jim/nut/drivers/dummy-ups, ...)
Network UPS Tools 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5) - Device simulation and repeater driver 0.23
   0.000000     [D1] debug level is '5'
   0.000033     [D5] send_to_all: SETINFO driver.debug "5"
   0.000049     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.000216     [D1] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000
   0.000253     [D1] Signalling UPS [dummy]: driver.exit (quietly, no fuss if no driver is running or responding)
   0.000287     Can't open /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy: No such file or directory
   0.000304     [D1] Request for other driver to exit returned code -1
   0.000335     [D1] Socket dialog with the other driver instance (may be absent) failed: No such file or directory
   0.000375     [D1] PID file /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid not found; stat() returned -1: No such file or directory
   0.001021     [D1] Saving PID 94910 into /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid
   0.001090     [D5] send_to_all: SETINFO device.type "ups"
   0.001124     [D5] send_to_all: SETINFO driver.state "init.device"
   0.001131     [D2] Dummy (simulation) mode with a sequence file name pattern (looping infinitely)
   0.001136     [D1] Dummy (simulation) mode looping infinitely
   0.001166     [D5] send_to_all: SETINFO driver.parameter.mode "dummy-loop"
   0.001180     [D2] Located dummy.seq for device simulation data: /home/jim/nut/tests/NIT/tmp/etc/dummy.seq
   0.001222     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.001231     [D5] send_to_all: SETINFO driver.version "2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1"
   0.001262     [D5] send_to_all: SETINFO driver.version.internal "0.23"
   0.001295     [D5] send_to_all: SETINFO driver.name "dummy-ups"
   0.001327     [D5] send_to_all: SETINFO driver.state "init.info"
   0.001335     [D5] send_to_all: SETINFO ups.mfr "Dummy Manufacturer"
   0.001370     [D5] send_to_all: SETFLAGS ups.mfr RW STRING
   0.001401     [D5] send_to_all: SETAUX ups.mfr 32
   0.001408     [D5] send_to_all: SETINFO ups.model "Dummy UPS"
   0.001437     [D5] send_to_all: SETFLAGS ups.model RW STRING
   0.001443     [D5] send_to_all: SETAUX ups.model 32
   0.001448     [D5] send_to_all: SETINFO ups.status "OL"
   0.001480     [D5] send_to_all: SETFLAGS ups.status RW STRING
   0.001488     [D5] send_to_all: SETAUX ups.status 32
   0.001513     [D1] entering parse_data_file()
   0.001774     [D3] parse_data_file: variable "ups.status" with 2 args
   0.001810     [D5] send_to_all: SETINFO ups.status "OB"
   0.001847     [D3] parse_data_file: TIMER instruction with value "5"
   0.001876     [D1] suspending execution for 5 seconds...
   0.001884     [D5] send_to_all: DATAOK
   0.001914     [D5] send_to_all: ADDCMD load.off
   0.001922     [D5] send_to_all: ADDCMD shutdown.default
   0.001930     [D5] send_to_all: SETINFO driver.state "init.updateinfo"
   0.001958     [D1] upsdrv_updateinfo...

   1.002120     [D1] entering parse_data_file()
   1.002169     [D1] leaving (paused)...
   1.002181     [D5] send_to_all: SETINFO driver.state "init.quiet"
   1.002313     Listening on socket /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy
   1.002343     [D2] dstate_init: sock /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy open on fd 5
   1.002351     [D5] send_to_all: SETINFO driver.parameter.pollinterval "2"
   1.002354     [D5] send_to_all: SETINFO driver.parameter.synchronous "auto"
   1.002387     [D5] send_to_all: SETINFO device.mfr "Dummy Manufacturer"
   1.002410     [D5] send_to_all: SETINFO device.model "Dummy UPS"
   1.032150     WARNING: ./drivers/upsdrvctl was called directly on a system with systemd support.
    Please consider using 'upsdrvsvcctl' instead, to avoid conflicts with
    nut-driver service instances prepared by 'nut-driver-enumerator'!
   1.032206     [D1:start-dummy-parent] For more details see https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
   1.032243     [D1:start-dummy-parent] To silence this warning export NUT_QUIET_INIT_NDE_WARNING with any value
   1.032254     [D1:start-dummy-parent] upsdrvctl: successfully finished
   1.032261     [D1:start-dummy-parent] Completed the job of upsdrvctl tool, cleaning up and exiting now
   1.032267     [D1:start-dummy-parent] Completed the job of upsdrvctl tool, clean-up finished, exiting now
   1.032273     [D2:start-dummy-parent] a upsdrvctl sub-process (start-dummy-parent) is exiting now
:; NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc NUT_STATEPATH=`pwd`/tests/NIT/tmp/run ./drivers/upsdrvctl stop dummy
Network UPS Tools upsdrvctl - UPS driver controller 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5)
   0.000000     [D1:init] debug level for upsdrvctl is '5'
   0.000031     [D1:init] upsdrvctl commanding one driver (dummy): stop
   0.000037     [D1:stop-dummy] Stopping UPS: dummy
   0.000093     [D2:stop-dummy] Sending signal to /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid
   0.000162     [D3:stop-dummy] getprocname: /proc is an accessible directory, investigating
   0.000214     [D3:stop-dummy] getprocname: located symlink for PID 94924 at: /proc/94924/exe
   0.000258     [D1:stop-dummy] getprocname: determined process name for PID 94924: /home/jim/nut/drivers/.libs/dummy-ups
   0.000298     [D5:stop-dummy] compareprocnames: appending progname [dummy-ups] to []
   0.000334     [D4:stop-dummy] compareprocnames: total_prognames=2 (with NULL sentinel); got ['dummy-ups']
   0.000375     [D5:stop-dummy] compareprocnames: appending progbasename [dummy-ups] to []
   0.000406     [D1:stop-dummy] compareprocnames: case-sensitive base name hit for PID 94924 of '/home/jim/nut/drivers/.libs/dummy-ups'=>'dummy-ups' and checked 'dummy-ups'=>'dummy-ups'
   0.000412     [D4:stop-dummy] sendsignalpidaliases: collected 2 aliases (with NULL sentinel): 'dummy-ups'
   0.000492     [D3:stop-dummy] getprocname: /proc is an accessible directory, investigating
   0.000526     [D3:stop-dummy] getprocname: located symlink for PID 94924 at: /proc/94924/exe
   0.000581     [D1:stop-dummy] getprocname: determined process name for PID 94924: /home/jim/nut/drivers/.libs/dummy-ups
   0.000612     [D5:stop-dummy] compareprocnames: appending progname [dummy-ups] to []
   0.000620     [D4:stop-dummy] compareprocnames: total_prognames=2 (with NULL sentinel); got ['dummy-ups']
   0.000651     [D5:stop-dummy] compareprocnames: appending progbasename [dummy-ups] to []
   0.000656     [D1:stop-dummy] compareprocnames: case-sensitive base name hit for PID 94924 of '/home/jim/nut/drivers/.libs/dummy-ups'=>'dummy-ups' and checked 'dummy-ups'=>'dummy-ups'
   0.000660     [D4:stop-dummy] sendsignalpidaliases: collected 2 aliases (with NULL sentinel): 'dummy-ups'
   1.000959     [D3:stop-dummy] getprocname: /proc is an accessible directory, investigating
   1.001041     [D3:stop-dummy] getprocname: located symlink for PID 94924 at: /proc/94924/exe
   1.001059     [D1:stop-dummy] getprocname: determined process name for PID 94924: /home/jim/nut/drivers/.libs/dummy-ups
   1.001092     [D5:stop-dummy] compareprocnames: appending progname [dummy-ups] to []
   1.001124     [D4:stop-dummy] compareprocnames: total_prognames=2 (with NULL sentinel); got ['dummy-ups']
   1.001156     [D5:stop-dummy] compareprocnames: appending progbasename [dummy-ups] to []
   1.001166     [D1:stop-dummy] compareprocnames: case-sensitive base name hit for PID 94924 of '/home/jim/nut/drivers/.libs/dummy-ups'=>'dummy-ups' and checked 'dummy-ups'=>'dummy-ups'
   1.001175     [D4:stop-dummy] sendsignalpidaliases: collected 2 aliases (with NULL sentinel): 'dummy-ups'
   2.001367     fopen /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid: No such file or directory
   2.001416     [D2:stop-dummy] Sending signal to /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid failed, driver is finally down or wrongly owned
   2.001424     WARNING: ./drivers/upsdrvctl was called directly on a system with systemd support.
    Please consider using 'upsdrvsvcctl' instead, to avoid conflicts with
    nut-driver service instances prepared by 'nut-driver-enumerator'!
   2.001430     [D1:stop-dummy] For more details see https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
   2.001457     [D1:stop-dummy] To silence this warning export NUT_QUIET_INIT_NDE_WARNING with any value
   2.001463     [D1:stop-dummy] upsdrvctl: successfully finished
   2.001470     [D1:stop-dummy] Completed the job of upsdrvctl tool, cleaning up and exiting now
   2.001473     [D1:stop-dummy] Completed the job of upsdrvctl tool, clean-up finished, exiting now
   2.001477     [D2:stop-dummy] a upsdrvctl sub-process (stop-dummy) is exiting now

@jimklimov jimklimov added this to the 2.8.5 milestone Jan 23, 2026
@jimklimov jimklimov added enhancement service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug labels Jan 23, 2026
…bal debug_min from ups.conf also to upsdrvctl tool itself [networkupstools#3276]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov
Copy link
Member Author

Disregard OBS RPM complaints, they are due to recent tagging in history.

@jimklimov
Copy link
Member Author

jimklimov commented Jan 23, 2026

Screenshots with debug_min=5 in global section, and debug_min=0 in dummy driver section - much quieter in the middle of the text (compared to the post above):

:; NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc NUT_STATEPATH=`pwd`/tests/NIT/tmp/run ./drivers/upsdrvctl start dummy
Network UPS Tools upsdrvctl - UPS driver controller 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5)
   0.000000     [D1:init] debug level for upsdrvctl is '5'
   0.000032     [D2:init]
If you're not a NUT core developer, chances are that you're told to enable debugging
to see why a driver isn't working for you. We're sorry for the confusion, but this is
the 'upsdrvctl' wrapper, not the driver you're interested in.

Below you'll find one or more lines starting with 'exec:' followed by an absolute
path to the driver binary and some command line option. This is what the driver
starts and you need to copy and paste that line and append the debug flags to that
line (less the 'exec:' prefix).

Alternately, provide an additional '-d' (lower-case) parameter to 'upsdrvctl' to
pass its current debug level to the launched driver, and '-B' keeps it backgrounded.

   0.000043     [D1:init] upsdrvctl commanding one driver (dummy): start
   0.000052     [D1:start-dummy] Starting UPS: dummy
   0.000088     [D2:start-dummy] 3 remaining attempts
   0.000114     [D2:start-dummy] exec:  /home/jim/nut/drivers/dummy-ups -a dummy
   0.000366     [D1:start-dummy-child] forkexec: calling execv(/home/jim/nut/drivers/dummy-ups, ...)
Network UPS Tools 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5) - Device simulation and repeater driver 0.23
Listening on socket /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy
   1.017850     WARNING: ./drivers/upsdrvctl was called directly on a system with systemd support.
    Please consider using 'upsdrvsvcctl' instead, to avoid conflicts with
    nut-driver service instances prepared by 'nut-driver-enumerator'!
   1.017912     [D1:start-dummy-parent] For more details see https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
   1.017950     [D1:start-dummy-parent] To silence this warning export NUT_QUIET_INIT_NDE_WARNING with any value
   1.017959     [D1:start-dummy-parent] upsdrvctl: successfully finished
   1.017968     [D1:start-dummy-parent] Completed the job of upsdrvctl tool, cleaning up and exiting now
   1.017975     [D1:start-dummy-parent] Completed the job of upsdrvctl tool, clean-up finished, exiting now
   1.017983     [D2:start-dummy-parent] a upsdrvctl sub-process (start-dummy-parent) is exiting now
:; NUT_CONFPATH=`pwd`/tests/NIT/tmp/etc NUT_STATEPATH=`pwd`/tests/NIT/tmp/run ./drivers/upsdrvctl stop dummy
Network UPS Tools upsdrvctl - UPS driver controller 2.8.4.1223-1223+gc40e440b9+v2.8.5+rc1 (pre-release iteration of 2.8.5)
   0.000000     [D1:init] debug level for upsdrvctl is '5'
   0.000035     [D1:init] upsdrvctl commanding one driver (dummy): stop
   0.000042     [D1:stop-dummy] Stopping UPS: dummy
   0.000060     [D2:stop-dummy] Sending signal to /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid
   0.000124     [D3:stop-dummy] getprocname: /proc is an accessible directory, investigating
   0.000163     [D3:stop-dummy] getprocname: located symlink for PID 95004 at: /proc/95004/exe
   0.000175     [D1:stop-dummy] getprocname: determined process name for PID 95004: /home/jim/nut/drivers/.libs/dummy-ups
   0.000206     [D5:stop-dummy] compareprocnames: appending progname [dummy-ups] to []
   0.000214     [D4:stop-dummy] compareprocnames: total_prognames=2 (with NULL sentinel); got ['dummy-ups']
   0.000225     [D5:stop-dummy] compareprocnames: appending progbasename [dummy-ups] to []
   0.000230     [D1:stop-dummy] compareprocnames: case-sensitive base name hit for PID 95004 of '/home/jim/nut/drivers/.libs/dummy-ups'=>'dummy-ups' and checked 'dummy-ups'=>'dummy-ups'
   0.000234     [D4:stop-dummy] sendsignalpidaliases: collected 2 aliases (with NULL sentinel): 'dummy-ups'
   0.000315     [D3:stop-dummy] getprocname: /proc is an accessible directory, investigating
   0.000352     [D3:stop-dummy] getprocname: located symlink for PID 95004 at: /proc/95004/exe
   0.000365     [D1:stop-dummy] getprocname: determined process name for PID 95004: /home/jim/nut/drivers/.libs/dummy-ups
   0.000395     [D5:stop-dummy] compareprocnames: appending progname [dummy-ups] to []
   0.000405     [D4:stop-dummy] compareprocnames: total_prognames=2 (with NULL sentinel); got ['dummy-ups']
   0.000410     [D5:stop-dummy] compareprocnames: appending progbasename [dummy-ups] to []
   0.000415     [D1:stop-dummy] compareprocnames: case-sensitive base name hit for PID 95004 of '/home/jim/nut/drivers/.libs/dummy-ups'=>'dummy-ups' and checked 'dummy-ups'=>'dummy-ups'
   0.000424     [D4:stop-dummy] sendsignalpidaliases: collected 2 aliases (with NULL sentinel): 'dummy-ups'
   1.000686     fopen /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid: No such file or directory
   1.000779     [D2:stop-dummy] Sending signal to /home/jim/nut/tests/NIT/tmp/run/dummy-ups-dummy.pid failed, driver is finally down or wrongly owned
   1.000794     WARNING: ./drivers/upsdrvctl was called directly on a system with systemd support.
    Please consider using 'upsdrvsvcctl' instead, to avoid conflicts with
    nut-driver service instances prepared by 'nut-driver-enumerator'!
   1.000802     [D1:stop-dummy] For more details see https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
   1.000842     [D1:stop-dummy] To silence this warning export NUT_QUIET_INIT_NDE_WARNING with any value
   1.000853     [D1:stop-dummy] upsdrvctl: successfully finished
   1.000859     [D1:stop-dummy] Completed the job of upsdrvctl tool, cleaning up and exiting now
   1.000864     [D1:stop-dummy] Completed the job of upsdrvctl tool, clean-up finished, exiting now
   1.000871     [D2:stop-dummy] a upsdrvctl sub-process (stop-dummy) is exiting now

@jimklimov
Copy link
Member Author

Using -d option as in updrvctl -d start dummy did pass the tool's debug level to the driver as expected.

It also got the driver to run in the background yet log to terminal, and for some reason upsdrvctl stop dummy did not work (could not find PID files). But upsdrvctl -c exit dummy did work, so maybe should be a fallback for failed stop.

…"exit" it by protocol [networkupstools#3277]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… if the other side exited [networkupstools#3277]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ry_prepare() [networkupstools#3277]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…top, so upsdrvctl exits when the driver is gone [networkupstools#3277]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>

memset(buf, 0, sizeof(buf));
/* Post the query and wait for reply */
/* FIXME: coordinate with pollfreq? */

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: coordinate with pollfreq?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant