For Nagios server installation:
After the nagios server installation we will install the percona plugin on the nagios server.
Nagios Server
# cd /tmp
#  wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.5/percona-monitoring-plugins-1.1.5.tar.gz
# tar xzf percona-monitoring-plugins-1.1.5.tar.gz
# cd percona-monitoring-plugins-1.1.5/nagios/bin/
# cp * /usr/local/nagios/libexec/
Create the file for the database monitoring 
# vi /usr/local/nagios/etc/objects/mysql.cfg
# Define a host for the local machine
define host{
        use                     linux-server          
        host_name         testDB
        alias                   db
        address              IP_Address
        }
# Define an optional hostgroup for Linux machines
define hostgroup{
        hostgroup_name  mysql-servers ; The name of the hostgroup
        alias           mysql-server ; Long name of the group
        members         testDB    ; Comma separated list of hosts that belong to this group
        }
define hostgroup{
  hostgroup_name mysql-masters
  alias MySQL Servers
  members testDB    
 }
 define hostgroup{
  hostgroup_name mysql-slaves
  alias MySQL Servers
  members testDB    
}
# SERVICE DEFINITIONS
 define service {
   use    local-service
   host_name                 testDB
   service_description   Check MySQL Database 
   check_command   check_mysql
           }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             Free Memory
  check_command                   check_nrpe!rdba_unix_memory
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL PID
  check_command                   check_nrpe!rdba_mysql_pidfile
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL Processlist
  check_command                   check_mysql_processlist!states_count!16!32
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL Connections
  check_command                   check_mysql_connections
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL Active Threads
  check_command                   check_mysql_active_threads!40!400
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL InnoDB Idle Blocker
  check_command                   check_mysql_innodb!idle_blocker_duration!60!600
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL InnoDB Long Transaction 
  check_command                   check_mysql_innodb!max_duration!86400!172800
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL InnoDB Lock Waits 
  check_command                   check_mysql_innodb!waiter_count!10!25
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL Replication Running
  check_command                   check_mysql_replication_running
  }
 define service{
  use                             local-service
  hostgroup_name                  mysql-servers
  service_description             MySQL Replication Delay
  check_command                   check_mysql_replication_delay!300!600
  }
After this, add the below commands of percona in the commands.cfg
# vi /usr/local/nagios/etc/objects/commands.cfg
define command {
    command_name        check_mysql
    command_line           $USER1$/check_mysql -H $HOSTADDRESS$ 
    }
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$
  }
# vi /usr/local/etc/nagios/nagios.cfg
Add this line in the Linux Host section
cfg_file=/usr/local/nagios/etc/objects/mysql.cfg
# service nagios restart
Nagios Client
For Nagios client installation follow the below post
# cd /tmp
#  wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.5/percona-monitoring-plugins-1.1.5.tar.gz
# tar xzf percona-monitoring-plugins-1.1.5.tar.gz
# cd percona-monitoring-plugins-1.1.5/nagios/bin
# cp * /usr/local/nagios/libexec/
Open the nrpe.cfg file and paste the percona commands
# vi /usr/local/nagios/etc/nrpe.cfg
command[rdba_mysql_pidfile]=/usr/local/nagios/libexec/pmp-check-mysql-pidfile
command[check_mysql_deadlocks]=/usr/local/nagios/libexec/pmp-check-mysql-deadlocks -i 5 -w 12 -c 60
command[check_mysql_replication_running]=/usr/local/nagios/libexec/pmp-check-mysql-replication-running
#command[check_mysql_service]=/usr/local/nagios/libexec/check_mysqld.pl  -u root -p xx -a slow_queries -w 44 -c 55
command[check_mysql]=/usr/local/nagios/libexec/check_mysql
command[check_mysql_innodb]=/usr/local/nagios/libexec/pmp-check-mysql-innodb -C idle_blocker_duration -w 60 -c 600
command[check_mysql_innodb]=/usr/local/nagios/libexec/pmp-check-mysql-innodb -C max_duration -w 86400 -c 172800
command[check_mysql_active_threads]=/usr/local/nagios/libexec/pmp-check-mysql-status -x Threads_running -w 20 -c 40
command[rdba_unix_memory]=/usr/local/nagios/libexec/pmp-check-unix-memory -d -w 90 -c 95
command[check_mysql_deadlocks]=/usr/local/nagios/libexec/pmp-check-mysql-deadlocks -i 5 -w 12 -c 60
command[check_mysql_connections]=/usr/local/nagios/libexec/pmp-check-mysql-status -x Threads_connected -o / -y max_connections -T pct -w 80 -c 95
command[check_mysql_replication_delay]=/usr/local/nagios/libexec/pmp-check-mysql-replication-delay -w 650 -c 600
command[check_mysql_processlist]=/usr/local/nagios/libexec/pmp-check-mysql-processlist -w 80 -c 100
# service xinetd restart
Go to the Nagios URL: IP_Address/nagios, you'll see your DB Host with percona plugins services
| testDB | 

Comments
Post a Comment
Please give your review or ask question ?