monitower

nimble and trivial monitoring suite
Log | Files | Refs

commit 773799d18b305cfb28a16e7ac0dadb8f53f64bc7
parent 22e8d78c6e2c740d5bc34f922ffd203a03a0e4d5
Author: Josuah Demangeon <me@josuah.net>
Date:   Mon, 26 Oct 2020 04:05:00 +0100

more reliable mail checking

Diffstat:
MMakefile | 2++
Mcheck-mail | 10+++++-----
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,7 @@ PREFIX = /usr/local +all: + install: mkdir -p ${PREFIX}${DESTDIR}/bin cp -r monitower-* check-* ${PREFIX}${DESTDIR}/bin diff --git a/check-mail b/check-mail @@ -1,7 +1,7 @@ #!/bin/sh -eu export x "$@" -: ${port:=25} ${timeout:=1} ${host:=$(hostname)} +: ${port:=25} ${timeout:=1} ${host:=$(hostname)} ${mail:=root@$(hostname)} out() { echo "C: $*" >&2 @@ -9,9 +9,9 @@ out() { sleep 0.4 } -{ - out "EHLO monitoring" - out "MAIL from:<monitoring>" +({ + out "EHLO $(hostname)" + out "MAIL from:<monitoring@$(hostname)>" out "RCPT to:<$mail>" out "DATA" out "" @@ -26,4 +26,4 @@ out() { } | nc -w "$timeout" "$ip" "$port" | while read code line; do echo "S: $code $line" | tr -d '\r'>&2 case $code in (5*) exit 1 ;; esac -done +done) 2>&1 | awk '/^S: / { S++; X += ($2 >= 400) } 1 END { exit(!S || X) }'