#!/bin/bash # was intended to be a monitor for xen domains but is too unsophisticated. # see monitor-doms.pl for a far better example that's not vulnerable to # easy DoS etc. NEEDRESET=0 r=$1 if [ ! -f "/etc/xen/$r.cfg" ] ; then echo "Usage: $0 domname" echo "Available doms: " xm list exit 1; fi ## TESt HTTP TEST=`GET -t 4 http://$r/ | grep -i HTML` if [ "$TEST" == "" ] ; then NEEDRESET=1 echo "HTTP Failed $TEST" fi ## TEST POP3 TEST=`echo "QUIT" | nc -w 4 $r pop3 | grep OK` if [ "$TEST" == "" ] ; then NEEDRESET=1 echo "POP3 Failed $TEST" fi ### If reset needed, do it if [ "$NEEDRESET" -eq "1" ] ; then /usr/local/bin/domreset.sh $r fi