Zabbix监控Mysql数据库性能--脚本方式
# cat checkmysqlperformance.sh#!/bin/sh
#Create by Lance 2014.10.31
MYSQL_SOCK="/var/lib/mysql/mysql.sock"
HOME=/usr/local/zabbix/mysql
ARGS=1
if [ $# -ne "$ARGS" ];then
echo "Please input one arguement:"
fi
case $1 in
Ping)
result=`mysqladmin ping | grep -c alive `
echo $result
;;
Version)
result=`mysql -V | cut -d" " -f6 |awk -F "," '{print "V" $1}'`
echo $result
;;
Uptime)
result=`mysqladmin -S $MYSQL_SOCK status | cut -d" " -f2 `
echo $result
;;
Com_update)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -wCom_update | cut -d "|" -f3`
echo $result
;;
Com_begin)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_begin | cut -d "|" -f3`
echo $result
;;
Bytes_received)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Bytes_received | cut -d "|" -f3`
echo $result
;;
Bytes_sent)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Bytes_sent | cut -d "|" -f3`
echo $result
;;
Com_commit)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_commit | cut -d "|" -f3`
echo $result
;;
Com_delete)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_delete | cut -d "|" -f3`
echo $result
;;
Com_insert)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_insert | cut -d "|" -f3`
echo $result
;;
Questions)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Questions | cut -d "|" -f3`
echo $result
;;
Com_rollback)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_rollback | cut -d "|" -f3`
echo $result
;;
Com_select)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_select | cut -d "|" -f3`
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Com_select | cut -d "|" -f3`
echo $result
;;
Slow_queries)
result=`mysqladmin -S $MYSQL_SOCK extended-status | grep -w Slow_queries | cut -d "|" -f3`
echo $result
;;
esac
页:
[1]