#!/bin/sh
host=$1
if [ -z $host ]; then
echo "Usage: `basename $0` [HOST]"
exit 1
fi
log_name=$host".log"
while :; do
result=`ping -s 32 -W 1 -c 1 $host | grep 'bytes from '`
if [ $? -gt 0 ]; then
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - host $host is down"| tee -a $log_name
continue
else
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - host $host is ok -`echo $result | cut -d ':' -f 2`"| tee -a $log_name
fi
sleep 1 # avoid ping rain
done
#!/bin/sh
host=$1
if [ -z $host ]; then
echo "Usage: `basename $0` [HOST]"
exit 1
fi
log_name=$host".log"
while :; do
result=`curl --connect-timeout 1 -sL -w "%{http_code}" $host -o /dev/null`
if [ $result != 200 ]; then
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - host $host is down"| tee -a $log_name
sleep 1
continue
else
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - host $host is ok -`echo $result`"| tee -a $log_name
fi
sleep 1 # avoid ping rain
done
#!/bin/sh
host=$1
port=$2
if [ -z $host ]; then
echo "Usage: `basename $0` [HOST]"
exit 1
fi
log_name=$host".log"
while :; do
result=`/root/tcping -x 1 -w 1 $host $port| grep 'response'`
if [ $? -gt 0 ]; then
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - $host $port is down"| tee -a $log_name
continue
else
echo -e "`date +'%Y/%m/%d %H:%M:%S'` - $host $port is ok -`echo $result`"| tee -a $log_name
fi
sleep 1
done