天天看點

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 

      disks information 

                        ' >> $txt 

df -h >> $txt 

      mysql status 

                   ' >> $txt 

netstat -nlp|grep mysql >> $txt 

     3306 

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 

     3307 

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

     3308 

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

     3309 

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

cat $txt

參考:

<a target="_blank" href="http://my.oschina.net/u/1403438/blog/177495">http://my.oschina.net/u/1403438/blog/177495</a>