当前位置:Gxlcms > 数据库问题 > 开发监控MySQL数据库的脚本

开发监控MySQL数据库的脚本

时间:2021-07-01 10:21:17 帮助过:2人阅读

[root@Cacti chapter7]# vi  mysql_method.sh 

echo method1------------

if [ `lsof -i tcp:3306|wc -l` -gt 0 ]     #通过过虑端口号来取值判断 

  then

     echo "MySQL  is Running."

  else

    echo "MySQL is Stopped."

    /etc/init.d/mysqld start

fi


echo method2----------------------

if [ `netstat -lntup|grep mysqld|wc -l ` -gt 0 ]   #通过过滤进程名来取值判断

   then

      echo "MySQL is Running."

   else

      echo "MySQL is Stopped."

   /etc/init.d/mysqld start

fi


echo method3-------------------------

if [ `ps -ef|grep -v grep|grep mysql|wc -l ` -gt 0 ]    #通过传统的方式来判断 

  then

    echo "MySQL is Running."

  else

     echo "MySQL is Stopped."

     /etc/init.d/mysqld start

fi


本文出自 “sky9890” 博客,请务必保留此出处http://sky9896.blog.51cto.com/2330653/1946270

开发监控MySQL数据库的脚本

标签:监控、数据库、脚本

人气教程排行