mysql mpm下载mpm
wget -c http://www.shinguz.ch/download/mysql_performance_monitor-latest.tar.gz
tar xf mysql_performance_monitor-latest.tar.gz
yum install perl-File-Which perl-libwww-perl perl-Digest-SHA perl-DBD-MySQL perl-Time-HiRes
tar xf mysql_performance_monitor_agent-0.9.1.tar.gz
cd mysql_performance_monitor_agent-0.9.1
创建配置文件目录并复制配置文件
mkdir /etc/fpmmm/
cp etc/FromDualMySQLagent.conf.template /etc/fpmmm/FromDualMySQLagent.conf
将key添加到zabbix_agentd.conf
vim /etc/zabbix/zabbix_agentd.conf
/usr/local/mysql_performance_monitor_agent-0.9.1/FromDualMySQLagent.pl /etc/fpmmm/FromDualMySQLagent.conf
并且每分钟执行一次
[root@localhost local]# crontab -l
* * * * * /usr/local/mysql_performance_monitor_agent-0.9.1/FromDualMySQLagent.pl /etc/fpmmm/FromDualMySQLagent.conf >/dev/null
重启agentd
/etc/init.d/zabbix-agentd restart
mkdir -p /var/log/zabbix /var/log/zabbix/cache
chown -R zabbix: /var/log/zabbix /var/log/zabbix/cache
配置文件具体如下:
[root@localhost local]# egrep -v "^#|^$|^%" /etc/fpmmm/FromDualMySQLagent.conf
[default]
Type = mysqld
Debug = 2
LogFile = /var/log/zabbix/FromDualMySQLagent.log #如目录不存在则创建
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache #目录不存在则创建
Username = fpmmm #授权数据库 mysql -e "GRANT ALL ON *.* TO 'fpmmm'@'127.0.0.1' IDENTIFIED BY 'password';"
Password = password #用户授权完毕,本地测试即可
MysqlHost = 127.0.0.1
MysqlPort = 3306
ZabbixServer = 192.168.158.128
Disabled = false
Modules = process mysql myisam innodb
ClusterLog = /var/lib/mysql-cluster/ndb_1_cluster.log
PidFile = /var/lib/mysqld/mysqld.pid
[db1] # This MUST match Hostname in Zabbix! #需要和
Type = mysqld
MysqlPort = 3306
Modules = process mysql myisam slave
PidFile = /var/run/mysqld/mysqld.pid
修改配置文件
[root@localhost local]# vim /usr/local/mysql_performance_monitor_agent/lib/sendData.pm
# 注释掉的语句如下:
# $rc = &FromDualMySQLagent::checkConnectionToZabbixServer($main::gParameter{'ZabbixServer'}, $main::gParameter{'ZabbixServerPort'}, $main::gParameter{'Hostname'});
目录属组属主为zabbix
[root@localhost local]# ll /var/log/zabbix/cache/
total 0
-rw-r--r--. 1 zabbix zabbix 0 May 9 06:26 FromDualAgentCache.db1.cache
[root@localhost local]#
如果报如下内容则删除FromDualAgentCache.db1.cache即可 ERR : Load of cache file failed. rc=1301
最终日志如下:agent模板说明:导入即可
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状态)
MPM其它用途的模板:
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设备状态信息)