HTTP监控脚本
#!/bin/bash
#echo "172.25.11.10  http://172.25.11.10">>/etc/hosts
echo -e "
\033[31m start http\033[0m
\033[32m stop http\033[0m
\033[33m restart http\033[0m
\033[34m status http\033[0m
"

#watch -n 1 "systemctl status httpd|grep 'Active';\n;ps aux |grep http|grep /usr/sbin"
while true
do
read -p "input your ops start|stop|restart|status|quit " A
case $A in
        start)
        ps aux |grep http|grep /usr/sbin &>/dev/null
        [ $? == 0 ]&&echo "you needn't start"&&exit 0 ||systemctl start httpd &>/dev/null&&echo success start
        ;;
        stop)
        ps aux |grep http|grep /usr/sbin &>/dev/null
        [ $? == 0 ]&& systemctl stop httpd&&echo success stop&&exit 0||echo no start no stop
        ;;
        restart)
        ps aux |grep http|grep /usr/sbin &>/dev/null
        [ $? != 0 ]&&echo you just need start&&exit 0||systemctl restart httpd&&echo success restart&& exit 0
        ;;
        status)
        ps aux |grep http|grep /usr/sbin &>/dev/null
        [ $? == 0 ]&&systemctl status httpd&&exit 0||echo you neet to start&&exit 0
        ;;
        quit)
        exit 0
        ;;
        *)
        echo "retype please!"
        ;;
esac
done