From f5f6d9ac7364fd3257d91687efafcdd667354683 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Wed, 22 Jun 2011 08:31:49 +0100 Subject: [PATCH] rcheck: A periodic remote monitoring tool. Organization: Straylight/Edgeware From: Mark Wooding Initial commit. --- check | 20 +++++++++++++++ check.d/disks | 59 ++++++++++++++++++++++++++++++++++++++++++ check.d/logs | 10 ++++++++ check.d/updates | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ rcheck | 47 ++++++++++++++++++++++++++++++++++ 5 files changed, 204 insertions(+) create mode 100755 check create mode 100755 check.d/disks create mode 100755 check.d/logs create mode 100755 check.d/updates create mode 100755 rcheck 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 <