标签: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
标签:mysql监控
原文地址:http://10265013.blog.51cto.com/10255013/1768532