[Nut-upsuser] How verbose should NUT be by default?

Greg Troxel gdt at lexort.com
Mon Jan 9 18:20:37 GMT 2023

Jim Klimov via Nut-upsuser <nut-upsuser at alioth-lists.debian.net> writes:

>   The opposite opinion is that programs should be quiet until asked to
> squeak (e.g. by restarting with higher debug verbosity... "that would help
> troubleshooting why the rack went down last week, right!" says the sysadmin
> me).

That's a fair summary but my opinion is:

  daemon-type programs should not by default emit things to
  stdout/stderr, unless the daemon can't run.  Things like "upsd" started are ok in syslog at LOG_INFO and we could probably
  regularize that.

  version is not interesting, because it's easy to tell what version is
  installed, and a well-run system has only one copy of nut.  And -D can
  print it to find out; it will be the same after a failure or before.

  "upsmon -K", documented to return 0/1, should not print by default
    that there is no pidfile
    that a upsmon daemon is or is not running
    the location of POWERDOWNFLAG
    and even that POWERDOWNFLAG is not set
  I'm ok with printing one line to stdout that it is set, because that's
  a big deal.
  I'm -1 but not a big deal on printing that is NOT set, because that's
  I think it would be good to stat the dir containing POWERDOWNFLAG and
  print a warning if it is not there.

  All the notable things that lead to shutdown (UPS going on battery,
  lowbatt, decision to shutdown, setting FSD flag, setting killpower,
  calling shutdown) are fair game for syslog.

  syslog should mostly survive for post-mortem analysis

  console output is ephemeral anyway, usually

  extra info is harmful because it makes everything harder to read; a
  bigger haystack to find a needle (which may be not about nut)
Specifically, I find all of this to be noise:

  Network UPS Tools upsmon
  Note: A previous upsmon instance is already running!
  Usually it should not be running during OS shutdown,
  which is when checking POWERDOWNFLAG makes most sense.
  UPS: foo at localhost (primary) (power value 1)
  Using power down flag file /etc/killpower
  Power down flag is not set

as the man page says "retrrns 0 or 1" and this is replacing

  if [ -f /etc/killpower ]; then

upsmon startup:

  Network UPS Tools upsmon
  kill: No such process
  UPS: foo at localhost (primary) (power value 1)
  Using power down flag file /etc/killpower

again, all knowable statically from config.


  Network UPS Tools upsd
  fopen /var/db/nut/upsd.pid: No such file or directory
  Could not find PID file '/var/db/nut/upsd.pid' to see if previous upsd instance is already running!
  listening on port 3493
  listening on ::1 port 3493
  Connected to UPS [foo]: bestfortress-foo
  Found 1 UPS defined in ups.conf

again, all what was configured.

>   So here is a shout-out to other practitioners: should NUT programs print
> their banner and other info (e.g. competing daemon instance was/wasn't
> found and how that was determined) every time they start by default? Or
> should they indeed be revised to talk less (and then settings and
> init-scripts in packaging can be tweaked to retain current behavior should
> distros/users want to)? Note that an alternative is to redirect to
> /dev/null the messages in init-scripts and similar integrations instead.

It's not, because redirecting to /dev/null loses the ability for output
that is notable to appear.

And a question from me:

  Have you ever had a situation where the above verbose info, printed on
  stdout/stderr, was useful in diagnosing a previous problematic
  shutdown (a real one, not a testing one)?  If so please describe.

More information about the Nut-upsuser mailing list