{"id":2263,"date":"2015-06-30T12:47:16","date_gmt":"2015-06-30T12:47:16","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=2263"},"modified":"2024-01-27T17:37:28","modified_gmt":"2024-01-27T17:37:28","slug":"install-percona-monitoring-tools-for-nagios-mysql-plugins","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/install-percona-monitoring-tools-for-nagios-mysql-plugins","title":{"rendered":"Install Percona Monitoring Tools for Nagios &#8211; MySQL Plugins"},"content":{"rendered":"<p>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&#8217;s looking for the same!<\/p>\n<h2>Install Nagios on Ubuntu &#8211; steps:<\/h2>\n<p><small>(skip to <a href=\"#perconasetup\">Percona Monitoring Tools &#8211; Nagios Plugin Setup<\/a>)<\/small><\/p>\n<p><b>Install dependencies:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">sudo apt-get install build-essential libgd2-xpm-dev apache2-utils libssl-dev\r\n<\/pre>\n<\/blockquote>\n<p><b>Configure Nagios users &amp; group:<\/b><\/p>\n<p><!--more--><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">sudo useradd -m nagios\r\nsudo passwd nagios\r\nsudo groupadd nagcmd\r\nsudo usermod -a -G nagcmd nagios\r\nsudo usermod -a -G nagcmd www-data\r\n<\/pre>\n<\/blockquote>\n<p><b>Download nagios setup and plugins:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">wget http:\/\/prdownloads.sourceforge.net\/sourceforge\/nagios\/nagios-4.0.8.tar.gz\r\nwget http:\/\/nagios-plugins.org\/download\/nagios-plugins-2.0.3.tar.gz\r\n<\/pre>\n<\/blockquote>\n<p><b>Install Nagios:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">tar xzf nagios-4.0.8.tar.gz\r\ncd nagios-4.0.8\r\nsudo .\/configure --with-command-group=nagcmd\r\nsudo make all\r\nsudo make install\r\nsudo make install-init\r\nsudo make install-config\r\nsudo make install-commandmode\r\n\r\nsudo \/usr\/bin\/install -c -m 644 sample-config\/httpd.conf \/etc\/apache2\/sites-enabled\/nagios.conf\r\n\r\nsudo htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin\r\nsudo service apache2 restart\r\n<\/pre>\n<\/blockquote>\n<p><b>Install Nagios Plugins:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">tar xzf nagios-plugins-2.0.3.tar.gz\r\ncd nagios-plugins-2.0.3\r\nsudo .\/configure --with-nagios-user=nagios --with-nagios-group=nagios\r\nsudo make\r\nsudo make install\r\n<\/pre>\n<\/blockquote>\n<p><b>Installing &amp; configuring NRPE<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">$] wget http:\/\/garr.dl.sourceforge.net\/project\/nagios\/nrpe-2.x\/nrpe-2.15\/nrpe-2.15.tar.gz\r\n$] tar xzf nrpe-2.15.tar.gz\r\n$] cd nrpe-2.15\r\n\r\nCompile and install the NRPE addon.\r\n$] .\/configure\r\n\r\nYou may face following error:\r\n\t<b>\"checking for SSL libraries... configure: error: Cannot find ssl libraries\"<\/b>\r\n\r\nTry specifying ssl &amp; lib path as follows:\r\n$] .\/configure --with-ssl=\/usr\/bin\/openssl --with-ssl-lib=\/usr\/lib\/i386-linux-gnu\/\r\n\r\n General Options:\r\n -------------------------\r\n NRPE port:    5666\r\n NRPE user:    nagios\r\n NRPE group:   nagios\r\n Nagios user:  nagios\r\n Nagios group: nagios\r\n\r\n\r\nReview the options above for accuracy.  If they look okay,\r\ntype 'make all' to compile the NRPE daemon and client.\r\n...\r\n...\r\n...\r\n\r\n$] make all\r\n$] make install-plugin\r\n$] make install-daemon\r\n$] make install-daemon-config\r\n$] make install-xinetd\r\n$] service xinetd restart\r\n$] vi  \/etc\/xinetd.d\/nrpe\r\n\t# default: on\r\n\t# description: NRPE (Nagios Remote Plugin Executor)\r\n\tservice nrpe\r\n\t{\r\n\t\tflags           = REUSE\r\n\t\tsocket_type     = stream\r\n\t\tport            = 5666\r\n\t\twait            = no\r\n\t\tuser            = nagios\r\n\t\tgroup           = nagios\r\n\t\tserver          = \/usr\/local\/nagios\/bin\/nrpe\r\n\t\tserver_args     = -c \/usr\/local\/nagios\/etc\/nrpe.cfg --inetd\r\n\t\tlog_on_failure  += USERID\r\n\t\tdisable         = no\r\n\t\tonly_from       = 127.0.0.1 localhost\r\n\t}\r\n\r\n$] vi \/etc\/services \r\n\tnrpe            5666\/tcp                 NRPE\r\n$] service xinetd restart\r\n$] netstat -at | grep nrpe\r\n\ttcp        0      0 *:nrpe                  *:*                     LISTEN     \r\n<\/pre>\n<\/blockquote>\n<p><b>Configure:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">sudo vi \/usr\/local\/nagios\/etc\/objects\/contacts.cfg\r\ndefine contact{\r\n        contact_name                    nagiosadmin\r\n        use                             generic-contact\r\n        alias                           Nagios Admin;\r\n        email                           your-email@your-domain.com;\r\n}\r\n\r\nsudo vi \/etc\/apache2\/sites-enabled\/nagios.conf\r\n## Comment the following lines ##\r\n#   Order allow,deny\r\n#   Allow from all\r\n\r\n## Uncomment and Change lines as shown below ##\r\nOrder deny,allow\r\nDeny from all\r\nAllow from 127.0.0.1 192.168.1.0\/24\r\n<\/pre>\n<\/blockquote>\n<p><b>Enable Apache&#8217;s rewrite and cgi modules:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">sudo a2enmod rewrite\r\nsudo a2enmod cgi\r\n\r\n#Restart apache service.\r\nsudo service apache2 restart\r\n<\/pre>\n<\/blockquote>\n<p><b>Check nagios.conf file for any syntax errors and start nagios service:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">sudo \/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg\r\nsudo service nagios start\r\n<\/pre>\n<\/blockquote>\n<p>You should be able to view the nagios admin panel GUI through:<br \/>\nhttp\/\/localhost\/nagios\/<\/p>\n<p><a name=\"perconasetup\"><\/a><br \/>\nWell so until now we did the basic Nagios installation &amp; config, let us begin with main task&#8230;<\/p>\n<h2>Percona Nagios Plugins Installation and Configuration:<\/h2>\n<p>Navigate to Percana plugins download page: https:\/\/www.percona.com\/downloads\/percona-monitoring-plugins\/<\/p>\n<p>You can see the plugins directory by reviewing resources.cfg where we&#8217;re going to install the plugins:<\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">vi \/usr\/local\/nagios\/etc\/resource.cfg\r\n\t# Sets $USER1$ to be the path to the plugins\r\n\t$USER1$=\/usr\/local\/nagios\/libexec\r\n<\/pre>\n<\/blockquote>\n<p><b>Download and copy over the plugins to plugin directory:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">cd \/tmp\r\nwget https:\/\/www.percona.com\/downloads\/percona-monitoring-plugins\/1.1.5\/percona-monitoring-plugins-1.1.5.tar.gz\r\ntar -xzf percona-monitoring-plugins-1.1.5.tar.gz\r\ncd percona-monitoring-plugins-1.1.5\/nagios\/bin\r\ncp * \/usr\/local\/nagios\/libexec\/\r\n<\/pre>\n<\/blockquote>\n<p><b>Configuration for Percona plugins for Nagios:<\/b><br \/>\n(I&#8217;ve copied over all though you might not need all of them!<br \/>\nAlso not that commands like &#8216;check_mysql_deadlocks&#8217; reads percona.deadlocks table created by pt-deadlock-logger.)<\/p>\n<p><b>Define commands:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">root@server3:\/usr\/local\/nagios\/etc\/objects# vi commands.cfg\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_nrpe_service\r\n\t\tcommand_line    $USER1$\/check_nrpe -H $HOSTADDRESS$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_service\r\n\t\tcommand_line    $USER1$\/check_mysql -H $HOSTADDRESS$ --extra-opts=client@\/etc\/nagios\/mysql.cnf\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_nrpe\r\n\t\tcommand_line    $USER1$\/check_nrpe -H $HOSTADDRESS$ -c $ARG1$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_connections\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-status -H $HOSTADDRESS$ -x Threads_connected -o \/ -y max_connections -T pct -w 80 -c 95\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_active_threads\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-status -H $HOSTADDRESS$ -x Threads_running -w $ARG1$ -c $ARG2$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_processlist\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-processlist -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$\r\n\t\t}\r\n\r\n\tdefine command {\r\n\t\tcommand_name    check_mysql_innodb\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-innodb -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_replication_delay\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-replication-delay -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_replication_running\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-replication-running -H $HOSTADDRESS$\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_deadlocks\r\n\t\tcommand_line    $USER1$\/pmp-check-mysql-deadlocks -H $HOSTADDRESS$ -i 5 -w 12 -c 60\r\n\t\t}\r\n\r\n\tdefine command{\r\n\t\tcommand_name    check_mysql_table_checksum\r\n\t\tcommand_line    $USER1$\/pmp-check-pt-table-checksum -H $HOSTADDRESS$\r\n\t\t}\r\n<\/pre>\n<\/blockquote>\n<p><b>Define hosts, host-groups and services:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">root@server3:\/usr\/local\/nagios\/etc\/objects# vi localhost.cfg \r\n\r\n# Hosts \/ hostgroups\r\n\r\n\tdefine host{\r\n\t\tuse                     linux-server\r\n\t\thost_name               localhost\r\n\t\talias                   localhost\r\n\t\taddress                 127.0.0.1\r\n        }\r\n\r\n\tdefine hostgroup{\r\n\t\thostgroup_name mysql-servers\r\n\t\talias MySQL Servers\r\n\t\tmembers localhost\r\n\t}\r\n\r\n\tdefine hostgroup{\r\n\t\thostgroup_name mysql-masters\r\n\t\talias MySQL Servers\r\n\t\tmembers localhost\r\n\t}\r\n\r\n\tdefine hostgroup{\r\n\t\thostgroup_name mysql-slaves\r\n\t\talias MySQL Servers\r\n\t\tmembers localhost\r\n\t}\r\n\r\n# Services:\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             NRPE Service\r\n\t\tcheck_command                   check_nrpe_service\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Service\r\n\t\tcheck_command                   check_mysql_service\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             Free Memory\r\n\t\tcheck_command                   check_nrpe!rdba_unix_memory\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL PID\r\n\t\tcheck_command                   check_nrpe!rdba_mysql_pidfile\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Processlist\r\n\t\tcheck_command                   check_mysql_processlist!states_count!16!32\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL User Connections \r\n\t\tcheck_command                   check_mysql_processlist!max_user_conn!90!95\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Connections\r\n\t\tcheck_command                   check_mysql_connections\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Active Threads\r\n\t\tcheck_command                   check_mysql_active_threads!40!400\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL InnoDB Idle Blocker\r\n\t\tcheck_command                   check_mysql_innodb!idle_blocker_duration!60!600\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL InnoDB Long Transaction \r\n\t\tcheck_command                   check_mysql_innodb!max_duration!86400!172800\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL InnoDB Lock Waits \r\n\t\tcheck_command                   check_mysql_innodb!waiter_count!10!25\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Replication Running\r\n\t\tcheck_command                   check_mysql_replication_running\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-servers\r\n\t\tservice_description             MySQL Replication Delay\r\n\t\tcheck_command                   check_mysql_replication_delay!300!600\r\n\t\t}\r\n\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-masters\r\n\t\tservice_description             MySQL Deadlocks\r\n\t\tcheck_command                   check_mysql_deadlocks\r\n\t\t}\r\n\t\t\r\n\tdefine service{\r\n\t\tuse                             active-service\r\n\t\thostgroup_name                  mysql-slaves\r\n\t\tservice_description             MySQL Table Checksums\r\n\t\tcheck_command                   check_mysql_table_checksum\r\n\t\t}\r\n<\/pre>\n<\/blockquote>\n<p><b>Create database user:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">GRANT USAGE, SELECT, REPLICATION CLIENT on *.* to 'nagios'@'localhost' IDENTIFIED BY 'nagios';\r\n<\/pre>\n<\/blockquote>\n<p><b>Add the database user in configuration for nagios to access:<\/b><\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">vi \/etc\/nagios\/my.cnf\r\n\t[client]\r\n\tuser=nagios\r\n\tpassword=nagios\r\n<\/pre>\n<\/blockquote>\n<p>&#8211; Restart Nagios and review the nagios admin panel:<\/p>\n<blockquote style=\"background-color: beige;\">\n<pre style=\"white-space: pre-wrap;\">\/etc\/init.d\/nagios restart\r\n<\/pre>\n<\/blockquote>\n<p><b>Nagios Dashboard:<\/b><br \/>\n<img decoding=\"async\" src=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2015\/06\/nagios-monitoring.png\" alt=\"nagios monitoring\" \/><\/p>\n<p>Hope this helps.<\/p>\n<p><b>Update:<\/b><br \/>\nHope you have not missed &#8220;Effective MySQL Monitoring&#8221; Video from Baron (Percona):<br \/>\n<iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/YD0EfF36_fw\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p><b>References:<\/b><br \/>\nhttps:\/\/www.percona.com\/doc\/percona-monitoring-plugins\/1.1\/<br \/>\nhttps:\/\/www.percona.com\/doc\/percona-monitoring-plugins\/1.1\/_downloads\/config-example.txt<\/p>\n","protected":false},"excerpt":{"rendered":"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&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8,870,377],"tags":[883,886,885,884],"class_list":{"0":"post-2263","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-tools","8":"category-mysql-articles","9":"tag-mysql-monitoring-tools","10":"tag-mysql-plugins-for-nagios","11":"tag-nagios-plugins","12":"tag-percona-monitoring-tools-for-nagios"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/comments?post=2263"}],"version-history":[{"count":12,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2263\/revisions"}],"predecessor-version":[{"id":2279,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2263\/revisions\/2279"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=2263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=2263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=2263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}