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