Skip to content

Commit

Permalink
scripts/upsdrvsvcctl/upsdrvsvcctl.in, docs/man/upsdrvsvcctl.txt: prov…
Browse files Browse the repository at this point in the history
…ide a basic "status" operation [#2567]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 31, 2024
1 parent e003a29 commit 5e1f48b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/man/upsdrvsvcctl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ by using the 'maxretry' and 'retrydelay' options - see linkman:ups.conf[5].
*stop*::
Stop the UPS driver(s).

*status*::
Query run-time status of all configured devices (or one specified device).
Currently defers work to linkman:upsdrvctl[8], and does not report service
unit information.

*upsdrvsvcctl* also supports further operations for troubleshooting the
mapping of NUT driver section names to the service instance names (which
may differ due to limitations of various systems).
Expand Down
19 changes: 19 additions & 0 deletions scripts/upsdrvsvcctl/upsdrvsvcctl.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (C) 2016-2018 Eaton
# Copyright (C) 2020-2024 Jim Klimov <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -91,10 +92,21 @@ usage: $0 [OPTIONS] list [<ups>]
to list the mapping of service instances to device sections
list <ups> (optionally return the service instance name for one device)
usage: $0 [OPTIONS] status [<ups>]
status report run-time status for each driver in ups.conf
status <ups> (optionally return the status info only for one device)
Fields: UPSNAME UPSDRV PF_RUNNING PF_PID S_RESPONSIVE S_PID S_STATUS
(PF_* = according to PID file, if any; S_* = via socket protocol)
usage: $0 [OPTIONS] show-config [<ups>]
show-config <ups> output config section from ups.conf for device <ups>
show-config ...or all devices if no <ups> argument was passed
EOF

# TODO:
# status call $ENUMERATOR
# to list the mapping of service instances to device sections
# and report run-time status for each one

}

ACTION=""
Expand Down Expand Up @@ -132,6 +144,13 @@ while [ $# -gt 0 ]; do
eval $ENUMERATOR --show-all-configs ; exit $?
fi
;;
status)
# TODO: Add info about service units
echo "NOTE: Action '$1' is not implemented via services currently, will call upsdrvctl" >&2
RES=0
@SBINDIR@/upsdrvctl status $2 || RES=$?
exit $RES
;;
start|stop)
ACTION="$1"
if [ -n "$2" ] ; then
Expand Down

0 comments on commit 5e1f48b

Please sign in to comment.