一、环境说明
zabbix 2.2 in Centos 6.4 64bit
二、MPM(MySQL Performance Monitor)安装
1.依赖模块
yum install perl-File-Which perl-libwww-perl perl-Digest-SHA1 perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay
2. MPM安装部署
wget -c https://support.fromdual.com/admin/public/download.php?operation=download&file_name=mysql_performance_monitor-0.9.3.tar.gz&_ga=1.119331465.1052460578.1414394659
解压源码包,分两大部分,一部分是模板需要在ZABBIX平台导入,一部分是采集程序
#tar -zxvf mysql_performance_monitor-latest.tar.gz
mysql_performance_monitor_agent-0.9.1.tar.gz #采集程序
mysql_performance_monitor_templates-0.9.1.tar.gz #模板
解压模板,并导入zabbix平台
#tar -zxvf mysql_performance_monitor_templates-0.9.1.tar.gz
Template_FromDual.MySQL.mpm.xml (监控mpm agent本身,这个必须导入)
Template_FromDual.MySQL.server.xml (监控Linux系统跟数据库使用相关的附加项)
Template_FromDual.MySQL.process.xml (监控各种Linux进程[比如:mysqld,ndbd])
Template_FromDual.MySQL.mysql.xml (监控MySQL常用状态变量)
Template_FromDual.MySQL.innodb.xml (监控InnoDB存储引擎状态变量)
Template_FromDual.MySQL.myisam.xml (监控MyISAM存储引擎状态变量)
Template_FromDual.MySQL.master.xml (监控MySQL主从复制的Master状态)
Template_FromDual.MySQL.slave.xml (监控MySQL主从复制的Slave状态)
Template_FromDual.MySQL.ndb.xml (监控MySQL Cluster)
Template_FromDual.MySQL.galera.xml (监控MySQL Galera Cluster)
Template_FromDual.MySQL.pbxt.xml (监控PBXT存储引擎状态变量)
Template_FromDual.MySQL.aria.xml (监控Aria存储引擎的状态变量)
Template_FromDual.MySQL.drbd.xml (监控DRBD设备状态信息)
# mv mysql_performance_monitor_agent-0.9.1 /usr/local/zabbix/script/mpm
修改FromDualMySQLagent.pl中的zabbix_sender的路径:
cd /usr/local/zabbix/script/mpm
sed -i 's|/usr/local/bin|/usr/local/zabbix/bin/|g' FromDualMySQLagent.pl
修改配置文件
cp /usr/local/zabbix/script/mpm/etc/FromDualMySQLagent.conf.template /usr/local/zabbix/etc/zabbix_mpm.conf
cat zabbix_mpm.conf
[default]
Type = mysqld
Debug = 2
LogFile = /var/log/zabbix/FromDualMySQLagent.log
# Directory where the Cache files should be written to:
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache
# Information for MySQL connections:
Username = user
Password = password
MysqlHost = 127.0.0.1
MysqlPort = 3306
# Zabbix Server IP address
ZabbixServer = 10.6.9.8
# If section is disabled
Disabled = false
Modules = process mysql myisam innodb
# Special parameter which is used for module ndb and process
ClusterLog = /var/lib/mysql-cluster/ndb_1_cluster.log
PidFile = /var/lib/mysql/mysqld.pid
# All MySQL databases here
# Try to avoid section names with spaces!
[10.58.50.49] # This MUST match Hostname in Zabbix!
Type = mysqld
MysqlPort = 3306
Modules = process mysql myisam slave
PidFile = /data/mysql/data/mysql.pid #mysql server pid
将mpm添加到zabbix_agentd.conf
##*****Mysql Performance**********
UserParameter=FromDual.MySQL.check,/usr/local/zabbix/script/mpm/FromDualMySQLagent.pl /usr/local/zabbix/etc/zabbix_mpm.conf
新建日志目录
# mkdir -p /var/log/zabbix/cache
# 手动创建日志文件:
#touch /var/log/zabbix/FromDualMySQLagent.log
# 修改目录权限:
#chown zabbix.zabbix /var/log/zabbix/ -R
#chmod o+r /data/mysql/data/mysql.pid
重启zabbix agentd
/etc/init.d/zabbix_agentd restart
测试:
# /usr/local/zabbix/script/mpm/FromDualMySQLagent.pl /usr/local/zabbix/etc/zabbix_mpm.conf
返回值为1:表示MPM插件正常,重启zabbix_agent,加载mpm插件