码迷,mamicode.com
首页 > 数据库 > 详细

MySQLJk

时间:2016-04-28 12:28:06      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:mysql监控

#!/bin/sh

thrps () {

thr=`ps aux|grep mysql|wc -l`

if [ $thr -ge "3" ]

then

echo 1

else

echo 0

fi

}

mysqljs () {

mysql -uroot -p123456 -e "show variables like ‘key_buffer_size‘" >/tmp/myl 2>/dev/null

if [ $? == "0" ]

then

echo 1

else

echo 0

fi

}

lockwaiting () {

mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_current_waits‘"|grep "[0-9]"|awk ‘{print $2}‘

}

locktime () {

mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_time‘"|grep "[0-9]"|awk ‘{print $2}‘

}

lockavg () {mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_time_avg‘"|grep "[0-9]"|awk ‘{print $2}‘

}

lockmax () {mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_time_max‘"|grep "[0-9]"|awk ‘{print $2}‘

}

lockmax () {mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_time_max‘"|grep "[0-9]"|awk ‘{print $2}‘

}

lockwait () {mysql -uroot -p123456 -e "show global status like ‘Innodb_row_lock_waits‘"|grep "[0-9]"|awk ‘{print $2}‘

}

tablelockwaiting () {mysql -uroot -p123456 -e "show global status like ‘Table_locks_immediate‘"|grep "[0-9]"|awk ‘{print $2}‘

}

tablelockwaiting () {mysql -uroot -p123456 -e "show global status like ‘Table_locks_waited‘"|grep "[0-9]"|awk ‘{print $2}‘

}

master_slave () {mysql -uroot -p123456 -e "show slave status\G"|grep -o "Yes"|wc -l

}

slave_time () {mysql -uroot -p123456 -e "show slave status\G"|grep "Seconds_Behind_Master"|awk -F : ‘{print $2}‘

}

mysql_con () {mysqladmin -uroot -p123456 -S /tmp/mysql.sock status|awk -F ":" ‘{print $3}‘|cut -d " "  -f2

}

mysql_buffer () {

reads=`mysql -uroot -p123456 -e "show global status like ‘Innodb_buffer_pool_reads‘"|grep "[0-9]"|awk ‘{print $2}‘`

request=`mysql -uroot -p123456 -e "show global status like ‘Innodb_buffer_pool_read_requests‘"|grep "[0-9]"|awk ‘{print $2}‘`

m=$(echo "scale=2;$reads/$request"|bc)

echo $m

}

mysql_buffer () {

hit=`mysql -uroot -p123456 -e "show global status like ‘Qcache_hits‘"|grep "[0-9]"|awk ‘{print $2}‘`     

com=`mysql -uroot -p123456 -e "show global status like ‘Com_select‘"|grep "[0-9]"|awk ‘{print $2}‘`

m=$(echo "scale=2;$hit/$com"|bc)

echo $m

}

$1


本文出自 “学习linux” 博客,请务必保留此出处http://10265013.blog.51cto.com/10255013/1768532

MySQLJk

标签:mysql监控

原文地址:http://10265013.blog.51cto.com/10255013/1768532

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!