Recently a friend asked about Installing Percona Monitoring Tools for Nagios as he was facing a few issues. I managed to set-it-up on my ubuntu VM. Sharing the the work-log of Nagios and Percona Monitoring Plugins setup steps here for some-one who’s looking for the same!
Install Nagios on Ubuntu – steps:
(skip to Percona Monitoring Tools – Nagios Plugin Setup)
Install dependencies:
sudo apt-get install build-essential libgd2-xpm-dev apache2-utils libssl-dev
Configure Nagios users & group:
sudo useradd -m nagios sudo passwd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios sudo usermod -a -G nagcmd www-data
Download nagios setup and plugins:
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
Install Nagios:
tar xzf nagios-4.0.8.tar.gz cd nagios-4.0.8 sudo ./configure --with-command-group=nagcmd sudo make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin sudo service apache2 restart
Install Nagios Plugins:
tar xzf nagios-plugins-2.0.3.tar.gz cd nagios-plugins-2.0.3 sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios sudo make sudo make install
Installing & configuring NRPE
$] wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz $] tar xzf nrpe-2.15.tar.gz $] cd nrpe-2.15 Compile and install the NRPE addon. $] ./configure You may face following error: "checking for SSL libraries... configure: error: Cannot find ssl libraries" Try specifying ssl & lib path as follows: $] ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnu/ General Options: ------------------------- NRPE port: 5666 NRPE user: nagios NRPE group: nagios Nagios user: nagios Nagios group: nagios Review the options above for accuracy. If they look okay, type 'make all' to compile the NRPE daemon and client. ... ... ... $] make all $] make install-plugin $] make install-daemon $] make install-daemon-config $] make install-xinetd $] service xinetd restart $] vi /etc/xinetd.d/nrpe # default: on # description: NRPE (Nagios Remote Plugin Executor) service nrpe { flags = REUSE socket_type = stream port = 5666 wait = no user = nagios group = nagios server = /usr/local/nagios/bin/nrpe server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd log_on_failure += USERID disable = no only_from = 127.0.0.1 localhost } $] vi /etc/services nrpe 5666/tcp NRPE $] service xinetd restart $] netstat -at | grep nrpe tcp 0 0 *:nrpe *:* LISTEN
Configure:
sudo vi /usr/local/nagios/etc/objects/contacts.cfg define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin; email your-email@your-domain.com; } sudo vi /etc/apache2/sites-enabled/nagios.conf ## Comment the following lines ## # Order allow,deny # Allow from all ## Uncomment and Change lines as shown below ## Order deny,allow Deny from all Allow from 127.0.0.1 192.168.1.0/24
Enable Apache’s rewrite and cgi modules:
sudo a2enmod rewrite sudo a2enmod cgi #Restart apache service. sudo service apache2 restart
Check nagios.conf file for any syntax errors and start nagios service:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg sudo service nagios start
You should be able to view the nagios admin panel GUI through:
http//localhost/nagios/
Well so until now we did the basic Nagios installation & config, let us begin with main task…
Percona Nagios Plugins Installation and Configuration:
Navigate to Percana plugins download page: https://www.percona.com/downloads/percona-monitoring-plugins/
You can see the plugins directory by reviewing resources.cfg where we’re going to install the plugins:
vi /usr/local/nagios/etc/resource.cfg # Sets $USER1$ to be the path to the plugins $USER1$=/usr/local/nagios/libexec
Download and copy over the plugins to plugin directory:
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/
Configuration for Percona plugins for Nagios:
(I’ve copied over all though you might not need all of them!
Also not that commands like ‘check_mysql_deadlocks’ reads percona.deadlocks table created by pt-deadlock-logger.)
Define commands:
root@server3:/usr/local/nagios/etc/objects# vi 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$ }
Define hosts, host-groups and services:
root@server3:/usr/local/nagios/etc/objects# vi localhost.cfg # Hosts / hostgroups define host{ use linux-server host_name localhost alias localhost address 127.0.0.1 } define hostgroup{ hostgroup_name mysql-servers alias MySQL Servers members localhost } define hostgroup{ hostgroup_name mysql-masters alias MySQL Servers members localhost } define hostgroup{ hostgroup_name mysql-slaves alias MySQL Servers members localhost } # Services: define service{ use active-service hostgroup_name mysql-servers service_description NRPE Service check_command check_nrpe_service } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Service check_command check_mysql_service } define service{ use active-service hostgroup_name mysql-servers service_description Free Memory check_command check_nrpe!rdba_unix_memory } define service{ use active-service hostgroup_name mysql-servers service_description MySQL PID check_command check_nrpe!rdba_mysql_pidfile } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Processlist check_command check_mysql_processlist!states_count!16!32 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL User Connections check_command check_mysql_processlist!max_user_conn!90!95 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Connections check_command check_mysql_connections } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Active Threads check_command check_mysql_active_threads!40!400 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL InnoDB Idle Blocker check_command check_mysql_innodb!idle_blocker_duration!60!600 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL InnoDB Long Transaction check_command check_mysql_innodb!max_duration!86400!172800 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL InnoDB Lock Waits check_command check_mysql_innodb!waiter_count!10!25 } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Replication Running check_command check_mysql_replication_running } define service{ use active-service hostgroup_name mysql-servers service_description MySQL Replication Delay check_command check_mysql_replication_delay!300!600 } define service{ use active-service hostgroup_name mysql-masters service_description MySQL Deadlocks check_command check_mysql_deadlocks } define service{ use active-service hostgroup_name mysql-slaves service_description MySQL Table Checksums check_command check_mysql_table_checksum }
Create database user:
GRANT USAGE, SELECT, REPLICATION CLIENT on *.* to 'nagios'@'localhost' IDENTIFIED BY 'nagios';
Add the database user in configuration for nagios to access:
vi /etc/nagios/my.cnf [client] user=nagios password=nagios
– Restart Nagios and review the nagios admin panel:
/etc/init.d/nagios restart
Nagios Dashboard:
Hope this helps.
Update:
Hope you have not missed “Effective MySQL Monitoring” Video from Baron (Percona):
References:
https://www.percona.com/doc/percona-monitoring-plugins/1.1/
https://www.percona.com/doc/percona-monitoring-plugins/1.1/_downloads/config-example.txt