MySQL数据库的脚本该如何开发监控
更新:HHH   时间:2023-1-7


下面一起来了解下MySQL数据库的脚本该如何开发监控,相信大家看完肯定会受益匪浅,文字在精不在多,希望MySQL数据库的脚本该如何开发监控这篇短内容是你想要的。

操作系统: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

看完MySQL数据库的脚本该如何开发监控这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的行业资讯栏目。

返回数据库教程...