chiark / gitweb /
rcheck: A periodic remote monitoring tool.
[rcheck] / rcheck
CommitLineData
f5f6d9ac
MW
1#! /bin/sh
2###
3### Run everyday health checks on remote systems.
4
5set -e
6cd /usr/local/share/rcheck
7
8for host in "$@"; do
9
10 { { { set +e
11 tar czf - check check.d |
12 ssh "$host" '
13set -e
14cd /tmp
15
16i=0
17while :; do
18 tmpdir=check.$$.$i
19 if mkdir -m700 $tmpdir >/dev/null 2>&1; then break; fi
20 case $i in
21 500) echo >&2 "failed to create temporary directory"; exit 125 ;;
22 esac
23 i=$((i + 1))
24done
25trap "cd /; rm -rf /tmp/$tmpdir" INT TERM QUIT HUP EXIT
26cd $tmpdir
27
28tar xzf -
29./check'
30 rc=$?; set -e
31 case $rc in
32 0) ;;
33 *) echo >&2 "remote check process failed (rc = $rc)" ;;
34 esac
35 } 1>&3; } 2>&1 |
36 sed 's/^/!!! /'
37 } 3>&1 |
38 if read line; then
39 cat <<EOF
40###--------------------------------------------------------------------------
41### $host
42
43$line
44EOF
45 cat
46 fi
47done