log=/soft/logs/monitor.log
echo `date +‘%Y-%m-%d %H:%M:%S‘`
echo `date +‘%Y-%m-%d %H:%M:%S‘` > $log
host_ports=(
caifuxiang-slave-test=121.45.111.17:8080=/activate.html
ghcaiyuan-slave-test=121.45.111.17:8080=/activate.html
caifuxiang-app=121.45.111.17:8080=/activate.html
caifuxiang-app2=121.45.111.17:8080=/activate.html
ghcaiyuan-app=121.45.111.17:8080=/activate.html
gucaiyuan-app2=121.45.111.17:8080=/activate.html
caifuxiang-master-upload=121.45.111.17:8090=/upload/crossdomain.xml
ghcaiyuan-master-upload=121.45.111.17:8090=/upload/crossdomain.xml
)
#echo ${host_ports[*]}
for ((i=0;i<${#host_ports[@]};++i))
do
host_name=`echo ${host_ports[i]}|cut -d "=" -f 1`
host_port=`echo ${host_ports[i]}|cut -d "=" -f 2`
uri_path=`echo ${host_ports[i]}|cut -d "=" -f 3`
#echo $host_port
if curl http://$host_port$uri_path > /dev/null 2>&1
then
#echo "$host_name is ok"
if [ -z $notify_host ]; then
notify_host=$host_port
fi
else
echo "$host_name is not ok"
echo "$host_name is not ok" >> $log
fi
done
log_lines=`cat $log|wc -l`
#echo "$log lines: $log_lines"
if [ $log_lines -gt 1 ]; then
echo "send notify email using: $notify_host, log: $log"
curl http://$notify_host/admin/monitor.html?log=$log > /dev/null 2>&1
else
echo "everything is ok"
fi