1.
Yum Install Perl-libwww-perl
Yum Install Perl-file-which
Yum Install Perl-dbd-mysql
Yum Install PERL-DIGEST-SHA1
Yum Install Perl-time-hires
Yum Install Perl-crypt-ssleay
2. Testing
#!/usr/bin/perl-w
Use DBI;
My $database = "MySQL";
My $hostname = "localhost";
My $data _source = "Dbi:mysql: $database: $hostname";
My $username = "root";
My $password = "123";
My $dbh = Dbi->connect ($data _source, $username, $password)
Or die "Cant connect to $data _source";
Perl Test successfully tested
3. Import the monitoring template (13 templates) on the Zabbix server side
Template_fromdual.mysql.mpm.xml–> (required)
Template_fromdual.mysql.server.xml–> monitoring database-related Linux server performance templates
Template_fromdual.mysql.process.xml–> monitoring of various Linux processes
Template_fromdual.mysql.mysql.xml–> common state variables for monitoring MySQL
Template_fromdual.mysql.myisam.xml–> Monitoring MyISAM storage engine state variables
Template_fromdual.mysql.innodb.xml–> Monitoring InnoDB storage engine state variables
template_fromdual.mysql.master.xml–> Monitoring MySQL Master Status
template_fromdual.mysql.slave.xml–> monitoring MySQL slave status
4.agentd
Mkdir-p/USR/LOCAL/MPM
MV mysql_performance_monitor_agent-0.9/usr/local/mpm/
Cp/usr/local/mpm/etc/fromdualmysqlagent.conf.template/etc/zabbix_mpm.conf
Chown zabbix/etc/zabbix_mpm.conf
#mkdir/var/log/zabbix
#touch/var/log/zabbix/fromdualmysqlagent.log
#chown-R Zabbix:zabbix/var/log/zabbix
Vim/usr/local/etc/zabbix_agentd.conf
Userparameter=fromdual.mysql.check,/usr/local/mpm/fromdualmysqlagent.pl/etc/zabbix_mpm.conf
5. Configuration
MPM supports monitoring multiple instances
Set three levels of Defaut-->host-->instanc
Vim/etc/zabbix_mpm.conf
[Default]
Type = mysqld
Debug = 2
LogFile =/tmp/fromdualmysqlagent.log
# Information for MySQL connections:
Username = root
Password = 123
Mysqlhost = localhost
Mysqlport = 3306
Modules = Process MySQL MyISAM innodb
# Zabbix Server IP Address
Zabbixserver = x.x.x.x
The hostname defined in the #下面的主机名需要跟Zabbix server is consistent
[x.x.x.x]
Type = mysqld
Modules = MPM Server process MySQL MyISAM InnoDB
[mysql01-5.5.21] # This must match Hostname in zabbix!
Type = mysqld
Mysqlport = 3306
Modules = process MySQL myisam slave innodb master MPM server
Pidfile =/data/mysql/log/mysql.pid
Modify the Zabbix_sender path inside the fromdualmysqlagent.pl script:
# This was needed to find zabbix_sender!
$ENV {path}. = $ENV {path}. ':/usr/local/bin '; #将/usr/local/bin modified to Zabbix_sender path
chmod 755 Chown Zabbix:zabbix/usr/local/bin/zabbix_sender
This article is from the "Muzinan Technology blog" blog, make sure to keep this source http://muzinan110.blog.51cto.com/684213/1559785
Zabbix monitoring MySQL (Perl)