Skip to content

Commit

Permalink
Issue #67 healthcheck improvements, add MAXAGE variable
Browse files Browse the repository at this point in the history
  • Loading branch information
instantlinux committed Dec 19, 2023
1 parent 6a31ab4 commit 23cd688
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion images/nut-upsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV API_USER=upsmon \
DESCRIPTION=UPS \
DRIVER=usbhid-ups \
GROUP=nut \
MAXAGE=15 \
NAME=ups \
POLLINTERVAL= \
PORT=auto \
Expand All @@ -22,7 +23,8 @@ ENV API_USER=upsmon \
SERVER=master \
USER=nut \
VENDORID=
HEALTHCHECK CMD upsc $NAME@localhost:3493 2>&1|grep -q stale && exit 1 || true
HEALTHCHECK CMD upsc $NAME@localhost:3493 2>&1|grep -q stale && \
kill -SIGTERM -1 || true

RUN apk add --update nut=$NUT_VERSION \
libcrypto3 libssl3 libusb musl net-snmp-libs
Expand Down
3 changes: 2 additions & 1 deletion images/nut-upsd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This will expose TCP port 3493; to reach it with the standard Nagios plugin, set

As a read-only service intended for monitoring, this container makes no attempt to lock down network security.

Verified with the most-common type of UPS, the APC consumer-grade product; Tripp Lite models also (probably) work. Note that the usbhid-ups driver for APC requires you to provide the correct 12-digit hardware serial number. All other parameter defaults will work.
Verified with the most-common type of UPS, the APC consumer-grade product; Tripp Lite models also (probably) work. CyberPower models need a MAXAGE parameter set longer than default (25). Note that the usbhid-ups driver for APC requires you to provide the correct 12-digit hardware serial number. All other parameter defaults will work.

If you have a different model of UPS, contents of the files ups.conf, upsd.conf, upsmon.conf, and/or upsd.users can be overridden by mounting them to /etc/nut/local.

Expand All @@ -43,6 +43,7 @@ API_PASSWORD | | API password, if not using secret
DESCRIPTION | UPS | user-assigned description
DRIVER | usbhid-ups | driver (see [compatibility list](http://networkupstools.org/stable-hcl.html))
GROUP | nut | local group
MAXAGE | 15 | seconds before declaring driver non-responsive
NAME | ups | user-assigned config name
POLLINTERVAL | | Poll Interval for ups.conf
PORT | auto | device port (e.g. /dev/ttyUSB0) on host
Expand Down
3 changes: 3 additions & 0 deletions images/nut-upsd/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ EOF
echo " sdorder = $SDORDER" >> /etc/nut/ups.conf
fi
fi
if [ "$MAXAGE" -ne 15 ]; then
sed -i -e "s/^[# ]*MAXAGE [0-9]\+/MAXAGE $MAXAGE/" /etc/nut/upsd.conf
fi
if [ -e /etc/nut/local/upsd.conf ]; then
cp /etc/nut/local/upsd.conf /etc/nut/upsd.conf
else
Expand Down
2 changes: 1 addition & 1 deletion images/nut-upsd/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sources:
- https://github.com/instantlinux/docker-tools
- https://github.com/networkupstools/nut
type: application
version: 0.1.5
version: 0.1.6
appVersion: "2.8.1-r0"
dependencies:
- name: chartlib
Expand Down
2 changes: 2 additions & 0 deletions images/nut-upsd/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Default values for nut-upsd.
deployment:
env:
driver: usbhid-ups
maxage: 15
serial: mustbeset
securityContext:
privileged: true
Expand Down

0 comments on commit 23cd688

Please sign in to comment.