设为首页 加入收藏

TOP

mysql 数据库的巡检脚本实例
2018-01-18 06:06:49 】 浏览:120
Tags:mysql 数据库 巡检 脚本 实例

mysql 数据库的巡检脚本实例

 [root@mysql-back ~]# cat mysql_check.sh 
#!/bin/bash 
TXT=system_check_$(date +%F-%H:%M).txt 
echo ' 
      memory 
             ' >> $TXT 
free -m >> $TXT 

echo ' 

      disks information 
                        ' >> $TXT 
df -h >> $TXT 

echo ' 

      mysql status 
                   ' >> $TXT 
netstat -nlp|grep mysql >> $TXT 

echo ' 

     3306 
                   ' >> $TXT 

mysql -t -S /data/mysql/mysqldata3306/sock/mysql.sock -phabby -e "SHOW VARIABLES LIKE '%connection%';select substring_index(host,':',1),time,count(*)from INFORMATION_SCHEMA.processlist group by substring_index(host,':',1);SHOW STATUS LIKE '%connection%';" >> $TXT 

echo ' 

     3307 
                   ' >> $TXT 

mysql -t -S /data/mysql/mysqldata3307/sock/mysql.sock -phabby -e "SHOW VARIABLES LIKE '%connection%';select substring_index(host,':',1),time,count(*)from INFORMATION_SCHEMA.processlist group by substring_index(host,':',1);SHOW STATUS LIKE '%connection%';" >> $TXT 

echo ' 

     3308 
                   ' >> $TXT 

mysql -t -S /data/mysql/mysqldata3308/sock/mysql.sock -phabby -e "SHOW VARIABLES LIKE '%connection%';select substring_index(host,':',1),time,count(*)from INFORMATION_SCHEMA.processlist group by substring_index(host,':',1);SHOW STATUS LIKE '%connection%';" >> $TXT 

echo ' 

     3309 
                   ' >> $TXT 

mysql -t -S /data/mysql/mysqldata3309/sock/mysql.sock -phabby -e "SHOW VARIABLES LIKE '%connection%';select substring_index(host,':',1),time,count(*)from INFORMATION_SCHEMA.processlist group by substring_index(host,':',1);SHOW STATUS LIKE '%connection%';" >> $TXT 


cat $TXT
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL状态检查教程 下一篇mysql 运行状态分析 运行故障排查..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目