Zabbix监控mysql
1.1 客户端配置
1.1.1 安装客户端包
yum -y install unixODBC rpm -ivh zabbix-agent-3.0.3-1.el6.x86_64.rpm
1.1.2 编辑配置文件
注释所有添加以下内容 vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf UserParameter=mysql.version,mysql -V UserParameter=mysql.status[*],/etc/zabbix/scripts/chk_mysql.sh $1 UserParameter=mysql.ping,mysqladmin -uzabbix -p123456 -P3306 -h192.168.1.77 ping | grep -c alive
1.1.3 创建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 vim /etc/zabbix/scripts/chk_mysql.sh #!/bin/sh # ------------------------------------------------------------------------------- MYSQL_SOCK="/tmp/mysql.sock" MYSQL_USER='zabbix' MYSQL_PWD='123456' MYSQL_HOST='127.0.0.1' MYSQL_PORT='3306' ARGS=1 if [ $# -ne "$ARGS" ];then echo "Please input one arguement:" fi case $1 in Uptime) result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status|cut -f 2 -d":"|cut -f1 -d"T"` echo $result ;; Com_update) result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended- status |grep -w "Com_update"|cut -d"|" -f3` echo $result ;; Slow_queries) result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status |cut - f5 -d":"|cut -f1 -d"O"`
1.1.4 修改zabbix客户端指向服务端IP
sed -i 's#ServerActive=127.0.0.1#ServerActive=192.168.1.72#g' /etc/zabbix/zabbix_agentd.conf sed -i 's#Server=127.0.0.1#Server=192.168.1.72#g' /etc/zabbix/zabbix_agentd.conf /etc/init.d/zabbix-agent restart
1.1.5 Web端操作