http监控脚本


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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值