Percona Nagios Plugins Installation and Configuration

czxin788發表於2017-03-01

Percona Nagios Plugins Installation and Configuration

 

 

  本文主要講述了用percona-monitoring-plugins-nagios監控mysql的配置方法。

1       下載percona monitor nagios外掛

cd /usr/local/src

wget

tar -xzf percona-monitoring-plugins-1.1.5.tar.gz

cd percona-monitoring-plugins-1.1.5/nagios/bin

cp * /usr/local/nagios/libexec/

 

 

2       配置nagios server外掛目錄

vi /usr/local/nagios/etc/resource.cfg

       # Sets $USER1$ to be the path to the plugins

       $USER1$=/usr/local/nagios/libexec

 

3       nagios server上的配置

nagios server端:

vi  /usr/local/nagios/etc/objects/ commands.cfg

 

       define command{

                   command_name    check_nrpe_service

                   command_line    $USER1$/check_nrpe -H $HOSTADDRESS$

                   }

 

         define command{

                   command_name    check_mysql_service

                   command_line    $USER1$/check_mysql -H $HOSTADDRESS$ --extra-opts=client@/etc/nagios/mysql.cnf

                   }

 

         define command{

                   command_name    check_nrpe

                   command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

                   }

 

         define command{

                   command_name    check_mysql_connections

                   command_line    $USER1$/pmp-check-mysql-status -H $HOSTADDRESS$ -x Threads_connected -o / -y max_connections -T pct -w 80 -c 95

                   }

 

         define command{

                   command_name    check_mysql_active_threads

                   command_line    $USER1$/pmp-check-mysql-status -H $HOSTADDRESS$ -x Threads_running -w $ARG1$ -c $ARG2$

                   }

 

         define command{

                   command_name    check_mysql_processlist

                   command_line    $USER1$/pmp-check-mysql-processlist -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$

                   }

 

         define command {

                   command_name    check_mysql_innodb

                   command_line    $USER1$/pmp-check-mysql-innodb -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$

                   }

 

         define command{

                   command_name    check_mysql_replication_delay

                   command_line    $USER1$/pmp-check-mysql-replication-delay -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$

                   }

 

         define command{

                   command_name    check_mysql_replication_running

                   command_line    $USER1$/pmp-check-mysql-replication-running -H $HOSTADDRESS$

                   }

 

         define command{

                   command_name    check_mysql_deadlocks

                   command_line    $USER1$/pmp-check-mysql-deadlocks -H $HOSTADDRESS$ -i 5 -w 12 -c 60

                   }

 

         define command{

                   command_name    check_mysql_table_checksum

                   command_line    $USER1$/pmp-check-pt-table-checksum -H $HOSTADDRESS$

                   }

 

 

nagios server端:

vim /usr/local/nagios/etc/servers/mysql/ mysql02-2.111.cfg

 

### percona monitor plugin for mysql ################

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             NRPE Service

                check_command                   check_nrpe_service

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Service

                check_command                   check_mysql_service

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             Free Memory

                check_command                   check_nrpe!rdba_unix_memory

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL PID

                check_command                   check_nrpe!rdba_mysql_pidfile

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Processlist

                check_command                   check_mysql_processlist!states_count!16!32

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL User Connections

                check_command                   check_mysql_processlist!max_user_conn!90!95

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Connections

                check_command                   check_mysql_connections

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Active Threads

                check_command                   check_mysql_active_threads!40!400

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL InnoDB Idle Blocker

                check_command                   check_mysql_innodb!idle_blocker_duration!60!600

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL InnoDB Long Transaction

                check_command                   check_mysql_innodb!max_duration!86400!172800

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL InnoDB Lock Waits

                check_command                   check_mysql_innodb!waiter_count!10!25

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Replication Running

                check_command                   check_mysql_replication_running

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Replication Delay

                check_command                   check_mysql_replication_delay!300!600

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Deadlocks

                check_command                   check_mysql_deadlocks

                }

 

        define service{

                use                             mysql,srv-pnp

                host_name                       mysql02-2.111

                service_description             MySQL Table Checksums

                check_command                   check_mysql_table_checksum

                }

 

nagios server端:

cat /etc/nagios/mysql.cnf

[client]

user=nagios

password=123456

chown root:nagios /etc/nagios/mysql.cnf

chmod 640 /etc/nagios/mysql.cnf

 

 

重啟nagios 服務

/etc/init.d/nagios restart

 

4       在被監控的mysql端上的配置

建立mysql使用者,讓nagios可以連線:

GRANT processlist,SELECT, REPLICATION CLIENT on *.* to 'nagios'@'nagios server ip' IDENTIFIED BY 'nagios';

cat /usr/local/nagios/etc/nrpe.cfg

新增如下兩行:

## percona monitor plugin for mysql ###

command[rdba_unix_memory]=/usr/local/nagios/libexec/pmp-check-unix-memory -d -w 96 -c 98

command[rdba_mysql_pidfile]=/usr/local/nagios/libexec/pmp-check-mysql-pidfile

 

 

最終訪問nagios的監控如下:


5       參考文件

http://kedar.nitty-witty.com/blog/install-percona-monitoring-tools-for-nagios-mysql-plugins

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28916011/viewspace-2134513/,如需轉載,請註明出處,否則將追究法律責任。

相關文章