From: Mark Wooding Date: Wed, 22 Jun 2011 07:31:49 +0000 (+0100) Subject: rcheck: A periodic remote monitoring tool. X-Git-Url: https://git.distorted.org.uk/~mdw/rcheck/commitdiff_plain/f5f6d9ac7364fd3257d91687efafcdd667354683 rcheck: A periodic remote monitoring tool. Initial commit. --- f5f6d9ac7364fd3257d91687efafcdd667354683 diff --git a/check b/check new file mode 100755 index 0000000..92965e3 --- /dev/null +++ b/check @@ -0,0 +1,20 @@ +#! /bin/sh +### +### Run a collection of everyday health checks. + +set -e + +for check in check.d/[!#]*[!~]; do + { { { set +e; "$check"; rc=$?; set -e + case $rc in 0) ;; *) echo >&2 "failed (rc = $rc)" ;; esac + } >&3; } 2>&1 | + sed 's/^/E: /' + } 3>&1 | { + if read line; then + echo "## ${check##*/}" + echo "$line" + cat + echo + fi + } +done diff --git a/check.d/disks b/check.d/disks new file mode 100755 index 0000000..63a541a --- /dev/null +++ b/check.d/disks @@ -0,0 +1,59 @@ +#! /bin/bash +### +### Check the health of attached physical disks. + +set -e + +## Build a list of actual disk devices according to their buses. +disks= +for p in /sys/class/block/*; do + bus=none devtype=none idtype=none + while read code assg; do + case "$assg" in + DEVNAME=*) name=${assg#*=} ;; + ID_BUS=*) bus=${assg#*=} ;; + DEVTYPE=*) devtype=${assg#*=} ;; + ID_TYPE=*) idtype=${assg#*=} ;; + esac + done </dev/null 2>&1; then break; fi + case $i in + 500) echo >&2 "failed to create temporary directory"; exit 125 ;; + esac + i=$((i + 1)) +done +trap "cd /; rm -rf /tmp/$tmpdir" INT TERM QUIT HUP EXIT +cd $tmpdir + +tar xzf - +./check' + rc=$?; set -e + case $rc in + 0) ;; + *) echo >&2 "remote check process failed (rc = $rc)" ;; + esac + } 1>&3; } 2>&1 | + sed 's/^/!!! /' + } 3>&1 | + if read line; then + cat <