本篇文章主要介绍了" 开发监控MySQL数据库的脚本",主要涉及到方面的内容,对于其他数据库感兴趣的同学可以参考一下:
操作系统:CentOS release 6.8 (Final)[root@Cacti chapter7]# vi mysql_method.sh echo m...
操作系统: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数据库的脚本,包括了方面的内容,希望对其他数据库有兴趣的朋友有所帮助。
本文网址链接:http://www.codes51.com/article/detail_4391325.html