chiark / gitweb /
Allow a subset of checks to be run.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 16 Apr 2015 12:00:29 +0000 (13:00 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 16 Apr 2015 12:00:29 +0000 (13:00 +0100)
Now we can configure more and less frequent checks.

check
check.d/10.daemons [new file with mode: 0755]
check.d/10.logs [moved from check.d/logs with 100% similarity]
check.d/10.ntp [moved from check.d/ntp with 100% similarity]
check.d/30.disks [moved from check.d/disks with 100% similarity]
check.d/50.updates [moved from check.d/updates with 100% similarity]
rcheck

diff --git a/check b/check
index 74c7f80..0cde4f3 100755 (executable)
--- a/check
+++ b/check
@@ -4,9 +4,26 @@
 
 set -e
 
+fix () {
+  n=$1
+  while :; do
+    case $n in
+      0) break ;;
+      0*) n=${n#0} ;;
+      *) break ;;
+    esac
+  done
+  echo $n
+}
+min=$(fix ${1-0}) max=$(fix ${2-99})
+
 exec 4>&1
 rc=0
 for check in check.d/[!#]*[!~]; do
+  base=${check##*/}
+  seq=${base%%[!0-9]*}
+  if [ $min -gt $seq -o $seq -gt $max ]; then continue; fi
+
   nrc=$(
     exec 5>&1
     { { { set +e; "$check"; rc=$?; set -e
diff --git a/check.d/10.daemons b/check.d/10.daemons
new file mode 100755 (executable)
index 0000000..78dc3a3
--- /dev/null
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+rc=0
+
+check () {
+  path=$1
+  if [ -x $path ] && ! pgrep -x ${path##*/} >/dev/null; then
+    echo >&2 $path not running
+    rc=1
+  fi
+}
+
+check /usr/sbin/ekeyd
+check /usr/sbin/ekeyd-egd-linux
+check /usr/sbin/yaid
+
+exit $rc
similarity index 100%
rename from check.d/logs
rename to check.d/10.logs
similarity index 100%
rename from check.d/ntp
rename to check.d/10.ntp
similarity index 100%
rename from check.d/disks
rename to check.d/30.disks
similarity index 100%
rename from check.d/updates
rename to check.d/50.updates
diff --git a/rcheck b/rcheck
index c4f59a8..9849a39 100755 (executable)
--- a/rcheck
+++ b/rcheck
@@ -12,12 +12,29 @@ do
   prog=$(readlink "${prog##*/}")
 done
 
+args=""
+usage () {
+  echo "usage: ${0##*/} [-[MIN-][MAX]] [HOST...]"
+}
+while :; do
+  case $# in 0) break ;; esac
+  case $1 in
+    -) break ;;
+    --) shift; break ;;
+    -*[!0-9]*-* | -*-*[!0-9]*) usage >&2; exit 1 ;;
+    -*-) a=${1#-}; a=${a%-}; args="$a" ;;
+    -*-*) a=${1#-}; b=${a#*-}; a=${a%-*}; args="$a $b" ;;
+    -*[!0-9]*) usage >&2; exit 1 ;;
+    -*) a=${1#-}; args="0 $a" ;;
+    *) break ;;
+  esac
+  shift
+done
 case $# in 0) set -- $(expand-list /etc/slaves :rcheck_hosts) ;; esac
 
 exec 4>&1
 rc=0
 for host in "$@"; do
-
   nrc=$(
     exec 5>&1
     { { { set +e
@@ -39,7 +56,7 @@ trap "cd /; rm -rf /tmp/$tmpdir" INT TERM QUIT HUP EXIT
 cd $tmpdir
 
 tar xzf -
-./check'
+./check'" $args"
          rc=$?; set -e; echo $rc >&5
          case $rc in
            0) ;;