#!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 2002-01-29 23:04 MET by . # Source directory was `/home/peter/src/metacheck'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 925 -rwxr-xr-x metacheck-1.3/metacheck # 772 -rw-r--r-- metacheck-1.3/metacheck.awk # 1218 -rw-r--r-- metacheck-1.3/README # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # if mkdir _sh02199; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= metacheck-1.3/metacheck ============== if test ! -d 'metacheck-1.3'; then $echo 'x -' 'creating directory' 'metacheck-1.3' mkdir 'metacheck-1.3' fi if test -f 'metacheck-1.3/metacheck' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'metacheck-1.3/metacheck' '(file already exists)' else $echo 'x -' extracting 'metacheck-1.3/metacheck' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'metacheck-1.3/metacheck' && #!/bin/sh X MCAWK=/etc/metacheck.awk MAILTO=root@some.where X FULLNAME="DiskSuite Mirror Monitor" X LOGTMP1=/tmp/metacheck-$$.tmp1 LOGTMP2=/tmp/metacheck-$$.tmp2 X HOST="`uname -n`" X PATH=/usr/sbin:/usr/bin:/usr/opt/SUNWmd/sbin export PATH X rm -f $LOGTMP X if [ "$1" = "-N" ]; then # Netsaint mode X X if (metastat >$LOGTMP1 2>/dev/null); then X X if (awk -f $MCAWK <$LOGTMP1 >$LOGTMP2); then X X echo "DISKSUITE OK - All Mirrors are Online" X rm -f $LOGTMP1 $LOGTMP2 X exit 0 X X else X X echo "DISKSUITE CRITICAL - Mirror(s) need Maintenance" X rm -f $LOGTMP1 $LOGTMP2 X exit 2 X X fi X X else X X echo "DISKSUITE WARNING - Error getting DiskSuite status" X rm -f $LOGTMP1 $LOGTMP2 X exit 1 X X fi X else X (metastat | awk -f $MCAWK >$LOGTMP) || (cat <&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'metacheck-1.3/metacheck:' 'MD5 check failed' 3821c01ae590b10d4c3221d2fc4f7b65 metacheck-1.3/metacheck SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'metacheck-1.3/metacheck'`" test 925 -eq "$shar_count" || $echo 'metacheck-1.3/metacheck:' 'original size' '925,' 'current size' "$shar_count!" fi fi # ============= metacheck-1.3/metacheck.awk ============== if test -f 'metacheck-1.3/metacheck.awk' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'metacheck-1.3/metacheck.awk' '(file already exists)' else $echo 'x -' extracting 'metacheck-1.3/metacheck.awk' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'metacheck-1.3/metacheck.awk' && #!/bin/awk -f # # MetaCheck, version 1.3 # # metacheck - check output from metastat and generate a summary report # regarding mirror devices with problems (failed submirrors, or too few # submirrors) # # Author: Peter Erisson , 2002-01-30 # X BEGIN { errors=0 } /^d.*: Mirror/ { mirrorid=$1; parse=1; nmirrors=0 } /Submirror .*: d.*/ { if (parse==1) {submirrorno=$2 ; nmirrors++; submirrorid=$3 }} /maintenance/ { if (parse==1) {errors++; print "WARNING (needs maintenance): Mirror", mirrorid, "[ Submirror", submirrorno, submirrorid, "]" }} /^$/ { if (parse==1 && nmirrors < 2) { print "WARNING (configuration error): Mirror", mirrorid, "contains too few submirrors" }; parse=0 } END { if (errors > 0) {print "Total warnings: ", errors; exit errors }} SHAR_EOF (set 20 02 01 29 23 02 37 'metacheck-1.3/metacheck.awk'; eval "$shar_touch") && chmod 0644 'metacheck-1.3/metacheck.awk' || $echo 'restore of' 'metacheck-1.3/metacheck.awk' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'metacheck-1.3/metacheck.awk:' 'MD5 check failed' 10b25437be085125719ef4c70f4394ed metacheck-1.3/metacheck.awk SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'metacheck-1.3/metacheck.awk'`" test 772 -eq "$shar_count" || $echo 'metacheck-1.3/metacheck.awk:' 'original size' '772,' 'current size' "$shar_count!" fi fi # ============= metacheck-1.3/README ============== if test -f 'metacheck-1.3/README' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'metacheck-1.3/README' '(file already exists)' else $echo 'x -' extracting 'metacheck-1.3/README' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'metacheck-1.3/README' && X metacheck, version 1.3 X X This is a simple sh script (and an awk subscript) that can be use to monitor the status of DiskSuite mirrors and devices. X It can either be run by cron at regular intervals and then it'll send an email to a configurable mail address when it detects an error, or it can be called as a NetSaint plugin. X X X INSTALLATION X Modify the metacheck sh script and install "metacheck" and "metacheck.awk" in suitable directories. X Run "crontab -e" (as root) to add it to the crontab system. X 10 6,9,12,15,18 * * * /sbin/metacheck X X And/or modify your NetSaint configuration so that it'll be called as a plugin. X I use the following i our local NetSaint systems "commands.cfg" and "hosts.cfg" files: X command[check_disksuite]=/sbin/metacheck -N command[check_rdisksuite]=/bin/ssh -n $HOSTADDRESS$ sbin/metacheck -N X service[ns]=DiskSuite;0;24x7;10;10;5;Sun;30;24x7;1;1;1;;check_rdisksuite service[admium]=DiskSuite;0;24x7;10;10;5;Sun;30;24x7;1;1;1;;check_disksuite X X Please note that the script *only* checks for problematic mirrors (submirrors needing maintenance or too few submirrors). Not concats, or RAID5 devices! X Problems/patches/improvents can be sent to: X X Peter Eriksson SHAR_EOF (set 20 02 01 29 23 03 51 'metacheck-1.3/README'; eval "$shar_touch") && chmod 0644 'metacheck-1.3/README' || $echo 'restore of' 'metacheck-1.3/README' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'metacheck-1.3/README:' 'MD5 check failed' d42cca7c924094ff6aa27e0395bce6ea metacheck-1.3/README SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'metacheck-1.3/README'`" test 1218 -eq "$shar_count" || $echo 'metacheck-1.3/README:' 'original size' '1218,' 'current size' "$shar_count!" fi fi rm -fr _sh02199 exit 0