shell 监控mysql\nginx脚本

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

你可能感兴趣的:(shell 监控mysql\nginx脚本)