monitower

nimble and trivial monitoring suite
Log | Files | Refs

commit 768d089b7ff6546d0cda001df257f1cbee90b43d
parent 6cb26006d909c18986696430cde8f03d4d13f249
Author: Josuah Demangeon <me@josuah.net>
Date:   Sun, 25 Oct 2020 11:27:04 +0100

simplify further monitower-run and reduce output

We need to put as few code as possible in monitower-run, in particular in the
loop, as it runs every minute and once for each check.

Diffstat:
Mmonitower-run | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/monitower-run b/monitower-run @@ -12,7 +12,7 @@ check() { set -u +e mkdir -p "$MONITOWER_SPOOL/$host" - "$cmd" "$@" >&2 + "$cmd" "$@" >/dev/null 2>&1 case $? in (0) state=ok level=debug ;; @@ -20,19 +20,18 @@ check() { set -u +e esac logger -cs -t monitower -p "$MONITOWER_FACILITY.${level:-alert}" \ - time="$now" state="$state" "$@" + time="$NOW" state="$state" "$@" - echo "time=$now state=$state" >>$MONITOWER_SPOOL/$host/$name.log + echo "time=$NOW state=$state $*" >>$MONITOWER_SPOOL/$host/$name.log } : ${MONITOWER_SPOOL:=/var/spool/monitower} : ${MONITOWER_FACILITY:=local7} -now=$(date +%s) +NOW=$(date +%s) IFS=' ' -[ $# = 0 ] && set /etc/monitower.conf -sed -r 's,\\\\,\\s,g; s,\\",\\q,g' "$@" | while read line; do +while read line; do check $(echo $line | xargs -n 1) & -done +done <${1:-/etc/monitower.conf} wait