linux下apache监控脚本

#!/bin/shif [ ! -e /root/tmp ]then        mkdir -p /root/tmpfiDATA=`date +%Y_%m_%d_%H_%M_%S`DATA1=`date +%Y_%m_%d_%H_%M`IP=`/sbin/ifconfig eth0 | grep 'inet' | awk '{print $2} ' | sed -e "s/addr\://"`cd /root/tmp##Apache安装好后,不做大修改情况下,manual/license.html 是可以访问的if wget --timeout=5  --tries=2 [url]http://$IP/manual/license.htmlthen       [/url] echo "apache is good!!"        rm -f /root/tmp/license.html*else        echo "apache is downed at:"$DATA >> /root/tmp/log.txt        killall -9 httpd        sleep 1        ulimit -HSn 8192        /usr/local/apache2/bin/apachectl start &fi
在crontab里加上
*/3 * * * * sh /usr/local/src/monitor.sh > /dev/null 2>&1
Apache 监控脚本二
#!/bin/shif [ ! -e /root/tmp ];then        mkdir /root/tmpfiDATA=`date +%Y_%m_%d_%H_%M_%S`ps -ef|grep httpd|grep -v grep|grep -v monitorif [ $? -eq 0 ]then   echo "apache is ok"else   echo "apache is downed at:"$DATA >> /root/tmp/httpd.log.txt   killall httpd   sleep 1   ulimit -n 65535    ulimit -s unlimited -u unlimited    ulimit -c unlimited   /usr/local/apache2/bin/apachectl start &fi