监控Apache正常服务的方法
1,新建apache.php
<?php
echo 'ok';
?>
2,新建apache.sh
#!/bin/sh
ct=`wget -O /tmp/res http://192.168.0.2/apache.php 2>&1 | cat | grep "200 OK" | wc -l`
curl=`curl http://192.168.0.2/apache.php`
if [ $curl != ok -o $ct != 1 ]
then
sleep 3s
else
exit;
fi
3,配置crontab,每5分钟执行一次
*/5 * * * * sh /root/apache.sh > /dev/null



