zabbix监控mysql脚本(仅供参考)
mkdir /etc/zabbix/scripts/touch
/etc/zabbix/scripts/chk_mysql.sh
chmod u
+x /etc/zabbix/scripts/chk_mysql.sh
chown
-R zabbix.zabbix /etc/zabbix/scripts/chk_mysql.sh
/etc/zabbix/scripts/chk_mysql.sh
#
!/bin/sh
#
-------------------------------------------------------------------------------
# Author: kk
# Email: hao1cheng@
163.com
MYSQL_PWD
='123456'
MYSQL_HOST
='127.0.0.1'
MYSQL_PORT
='3306' echo
"Please input one arguement:"
fi
case $1 in echo $result
;;
Com_update)
echo $result
;;
Slow_queries)
;;
Com_select)
echo $result
;;
Com_rollback)
result
=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_rollbac
k"|cut -d"|" -f3`
echo $result
;;
Questions)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status|cut -f4 -d":"|cut -f1 -d"S"`
echo $result
;;
Com_insert)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_insert"
|cut -d"|" -f3`
echo $result
;;
Com_delete)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_delete"
|cut -d"|" -f3`
echo $result
;;
Com_commit)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_commit"
|cut -d"|" -f3`
echo $result
;;
Bytes_sent)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Bytes_sent"
|cut -d"|" -f3`
echo $result
;;
Bytes_received)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Bytes_recei
ved" |cut -d"|" -f3`
echo $result
;;
Com_begin)
result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_begin"|
cut -d"|" -f3`
echo $result
;;
*)
echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions)"
;;
esac
页:
[1]