首页 > 数据库技术 > 详细

开发监控MySQL数据库的脚本

时间:2017-07-11 14:19:02      阅读:336      评论:0      收藏:0      [点我收藏+]

操作系统:CentOS release 6.8 (Final)

[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数据库的脚本

原文:http://sky9896.blog.51cto.com/2330653/1946270

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!