Skip to content

drivers/upsdrvctl: add "-d" option to pass current debug level from upsdrvctl to drivers#1287

Merged
jimklimov merged 3 commits intonetworkupstools:masterfrom
jimklimov:upsdrvctl-debug-pass
Feb 16, 2022
Merged

drivers/upsdrvctl: add "-d" option to pass current debug level from upsdrvctl to drivers#1287
jimklimov merged 3 commits intonetworkupstools:masterfrom
jimklimov:upsdrvctl-debug-pass

Conversation

@jimklimov
Copy link
Member

@jimklimov jimklimov commented Feb 14, 2022

Closes: #1036

(Note: that issue discusses other possible improvements around this subject, which are synergetic with this one and posted as separate issues and PRs)

@jimklimov jimklimov force-pushed the upsdrvctl-debug-pass branch from 90a39aa to 10619ae Compare February 14, 2022 12:27
Closes: networkupstools#1036

(Note: that issue discusses other possible improvements around this
subject, which are synergetic with this one)
@jimklimov jimklimov force-pushed the upsdrvctl-debug-pass branch from 10619ae to 3718f46 Compare February 14, 2022 13:31
@jimklimov
Copy link
Member Author

jimklimov commented Feb 14, 2022

Tested for debug levels above and under a limit for the argument length (8 in the test, SMALLBUF=512 in PR):
(UPDATED for commits posted later, to avoid useless suggestions when -d is in fact used)

Small values are ok, not expanded to top-verbosity logging :)

# ./drivers/upsdrvctl -DD -d start nutdev1
Network UPS Tools - UPS driver controller 2.7.4-4656-g0007056
   0.000000     [D1] Starting UPS: nutdev1
   0.000680     [D2] 1 remaining attempts
   0.001258     [D2] exec:  /usr/local/ups/bin/usbhid-ups -DD -a nutdev1
Network UPS Tools - Generic HID driver 0.45 (2.7.4-4652-gb559cc4)
USB communication driver (libusb 1.0) 0.42
   0.000000     [D1] debug level is '2'
...

Truncation to fit in 8-char arg, reported in upsdrvctl log:

# ./drivers/upsdrvctl -DDDDDDDD -d start nutdev1
Network UPS Tools - UPS driver controller 2.7.4-4656-g0007056
   0.000000     [D1] Starting UPS: nutdev1
   0.000752     [D1] Requested debugging level 8 is too high for pass-through args, truncated to 6
   0.001410     [D2] 1 remaining attempts
   0.002004     [D2] exec:  /usr/local/ups/bin/usbhid-ups -DDDDDD -a nutdev1
Network UPS Tools - Generic HID driver 0.45 (2.7.4-4652-gb559cc4)
USB communication driver (libusb 1.0) 0.42
   0.000000     [D5] send_to_all: SETINFO driver.parameter.port "auto"
   0.000749     [D5] send_to_all: SETINFO driver.parameter.vendorid "0463"
   0.001376     [D5] send_to_all: SETINFO driver.parameter.productid "FFFF"
   0.001995     [D5] send_to_all: SETINFO driver.parameter.product "Protection Station"
   0.002633     [D5] send_to_all: SETINFO driver.parameter.serial "AN2E49008"
   0.003255     [D5] send_to_all: SETINFO driver.parameter.vendor "EATON"
   0.003853     [D5] send_to_all: SETINFO driver.parameter.bus "003"
   0.004633     [D1] debug level is '6'
...

No logging is passed-through without -d option, and it is suggested along with the earlier notes for launching the driver itself with debugging options:

# ./drivers/upsdrvctl -DD start nutdev1
Network UPS Tools - UPS driver controller 2.7.4-4656-g0007056
   0.000000     [D2]
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.

   0.004182     [D1] Starting UPS: nutdev1
   0.004980     [D2] 1 remaining attempts
   0.005226     [D2] exec:  /usr/local/ups/bin/usbhid-ups -a nutdev1
Network UPS Tools - Generic HID driver 0.45 (2.7.4-4652-gb559cc4)
USB communication driver (libusb 1.0) 0.42
...

Not much logging by default:

# ./drivers/upsdrvctl start nutdev1
Network UPS Tools - UPS driver controller 2.7.4-4652-gb559cc4
Network UPS Tools - Generic HID driver 0.45 (2.7.4-4652-gb559cc4)
USB communication driver (libusb 1.0) 0.42
...

@jimklimov jimklimov added the service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Investigate an option to forward debug flags from upsdrvctl to actual driver

1 participant