#!/bin/sh

monitor web run

#by zkg 2019-08-05

#下面是多种方式来判断mysql是否启动
#local 监控
#if [ "netstat -lnt |grep 80|awk '{print $4}'|awk -F: '{print $2}'" = "80" ]
#if [ ps -ef |grep httpd|grep -v grep|wc -l -gt 0 ]
#if [ netstat -lntup|grep httpd|wc -l -gt 0 ]
#if [ lsof -i tcp:80|wc -l -gt 0 ]

#remote 监控
#if [ nmap www.baidu.com -p 80 2>/dev/null|grep open|wc -l -gt 0 ]
#if [ "curl -I -s -o /dev/null -w "%{http_code}\n" http://www.baidu.com" = "200" ]
#if [ curl -I http://www.baidu.com 2>/dev/null|head -1|egrep "200|301"|wc -l -eq 1 ]

then
    echo "httpd is running"

else
echo "httpd is stopped"
/data/http/bin/httpd start
fi