shell 监控mysqlnginx脚本

2022-05-14 15:54:09 浏览数 (1)

1、mysql

!/bin/sh

port=netstat -lnt|grep 3306|wc -l

if [ $port -ne 1 ];then

echo "mysql is stop"

/etc/init.d/mysqld start

else

echo "mysql is starting"

fi 2、监控Nginx

!/bin/sh

port=netstat -lnt|grep 80|wc -l

if [ $port -ne 1 ];then

echo "nginx is stop"

/usr/sbin/nginx

else

echo "nginx is starting"

fi

0 人点赞