0)监控本地httpd服务情况,通过检测端口与进程信息进行监测
[root@jason ~]# cat check_http.sh#!/bin/bash
httpd_port=`netstat -antulp|grep httpd|wc -l`httpd_process=`ps -ef |grep httpd|grep -v grep|wc -l`httpd_log=/tmp/httpd.loghttpd_init=/etc/init.d/httpd
if [ $httpd_port -eq 1 ] && [ $httpd_process -eq 9 ]thenecho "httpd is running"elseecho "httpd is not running"$httpd_init start >$httpd_log
sleep 10
httpd_port=`netstat -antulp|grep httpd|wc -l`httpd_process=`ps -ef |grep httpd|grep -v grep|wc -l`
if [ $httpd_port -ne 1 -a $httpd_process -ne 9 ]thenwhile truedokillall httpd[ $? -ne 0 ] && breaksleep 1