{"id":2296,"date":"2015-08-17T11:47:46","date_gmt":"2015-08-17T11:47:46","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=2296"},"modified":"2024-01-27T17:29:44","modified_gmt":"2024-01-27T17:29:44","slug":"how-to-add-remote-mysql-server-to-nagios-monitoring","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/how-to-add-remote-mysql-server-to-nagios-monitoring","title":{"rendered":"How to Add Remote MySQL Server to Nagios Monitoring"},"content":{"rendered":"\n<p>We already have seen two articles for setting up MySQL Monitoring with <a href=\"kedar.nitty-witty.com\/10-steps-mysql-monitoring-nagios-installation-configuration\" target=\"_blank\" rel=\"nofollow noopener\">Nagios<\/a> and <a href=\"kedar.nitty-witty.com\/install-percona-monitoring-tools-for-nagios-mysql-plugins\" target=\"_blank\" rel=\"nofollow noopener\">Percona Monitoring Tools for Nagios<\/a>. Those posts covers configuration of nagios on single instance.<\/p>\n\n\n\n<p>Though following questions came to me: Do you need to setup Nagios again on all servers that we want to monitor? How do you add another MySQL server to this monitoring?<\/p>\n\n\n\n<p>This post is an answer to those questions.<\/p>\n\n\n\n<p>To add remote server to nagios monitoring, We need NRPE (Nagios Remote Plugin Executor) along with Xinetd (Extended Internet Daemon) and Nagios Plugins to be setup.<\/p>\n\n\n\n<p>(This assumes you have already setup the nagios server and adding new host. Refer links in first line of the article)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to add Remote MySQL server to Nagios Monitoring:<\/h3>\n\n\n\n<!--more-->\n\n\n\n<p><strong>&#8211; Create MySQL user for Nagios Server to connect (on Remote Server):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">GRANT USAGE, REPLICATION CLIENT ON *.* TO 'nagios'@'' IDENTIFIED BY 'nagios';\n<\/pre>\n\n\n\n<p><strong>&#8211; Install required dependencies:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install xinetd openssl openssl-devel\n# OR apt-get install openssl xinetd libssl-dev\n<\/pre>\n\n\n\n<p><strong>&#8211; Download &amp; Install Nagios Plugins on remote MySQL Server:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget http:\/\/nagios-plugins.org\/download\/nagios-plugins-2.0.3.tar.gz\ntar xzf nagios-plugins-2.0.3.tar.gz\ncd nagios-plugins-2.0.3\nsudo .\/configure --with-nagios-user=nagios --with-nagios-group=nagios\nsudo make\nsudo make install\n<\/pre>\n\n\n\n<p><strong>&#8211; Download &amp; Install NRPE:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget http:\/\/garr.dl.sourceforge.net\/project\/nagios\/nrpe-2.x\/nrpe-2.15\/nrpe-2.15.tar.gz\ntar xzf nrpe-2.15.tar.gz\ncd nrpe-2.15\n\n##Compile and install the NRPE addon.\n.\/configure\n<\/pre>\n\n\n\n<p>You may face following error:<br><b>&#8220;checking for SSL libraries&#8230; configure: error: Cannot find ssl libraries&#8221;<\/b><\/p>\n\n\n\n<p>Try specifying ssl &amp; lib path as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/configure --with-ssl=\/usr\/bin\/openssl --with-ssl-lib=\/usr\/lib\/i386-linux-gnu\/\n<\/pre>\n\n\n\n<p>If this still doesn&#8217;t get resolved make sure you have required openssl and dependencies sorted.<\/p>\n\n\n\n<p><strong>&#8211; Proceed further for the NRPE setup:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">make all\nmake install-plugin\nmake install-daemon\nmake install-daemon-config\nmake install-xinetd\nservice xinetd restart\nvi  \/etc\/xinetd.d\/nrpe # Verify following content (Note only_from)\n\n<i># default: on\n\t# description: NRPE (Nagios Remote Plugin Executor)\n\tservice nrpe\n\t{\n\t\tflags           = REUSE\n\t\tsocket_type     = stream\n\t\tport            = 5666\n\t\twait            = no\n\t\tuser            = nagios\n\t\tgroup           = nagios\n\t\tserver          = \/usr\/local\/nagios\/bin\/nrpe\n\t\tserver_args     = -c \/usr\/local\/nagios\/etc\/nrpe.cfg --inetd\n\t\tlog_on_failure  += USERID\n\t\tdisable         = no\n\t\t<b>only_from       = 127.0.0.1 192.168.86.129<\/b>\n\t}<\/i>\n<\/pre>\n\n\n\n<p>As we&#8217;re going to run NRPE daemon xinetd, we&#8217;ll need to add the IP\/hostname to the only_from directive.<br>We need to update allowed_hosts in the file \/usr\/local\/nagios\/etc\/nrpe.cfg if we&#8217;re not going to use NRPE with Xinetd.<br><strong>Note<\/strong> that <em>allowed_hosts is a comma-delimited list while only_from is space separated.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/services # Add following line.\n\tnrpe            5666\/tcp                 NRPE\n\nservice xinetd restart\nnetstat -at | grep nrpe # Confirm that the nrpe is listening.\n\ntcp        0      0 *:nrpe                  *:*                     LISTEN     \n<\/pre>\n\n\n\n<p><strong>&#8211; Once setup is done you can check the NRPE:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">MySQL-Server]# \/usr\/local\/nagios\/libexec\/check_nrpe -H localhost\nNRPE v2.15\n<\/pre>\n\n\n\n<p>and also from the Nagios server (replace the IP with that of remote server):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@Nagios-Server:# \/usr\/local\/nagios\/libexec\/check_nrpe -H 192.168.86.129 -p 5666 \nNRPE v2.15\n<\/pre>\n\n\n\n<p><strong>Some debugging:<\/strong><\/p>\n\n\n\n<p>If you receive errors as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">root@Nagios-Server:# \/usr\/local\/nagios\/libexec\/check_nrpe -H 192.168.86.129 -p 5666 \nCHECK_NRPE: Error - Could not complete SSL handshake.\n<\/pre>\n\n\n\n<p>&#8230; make sure to confirm the configuration (only_from), connectivity or the firewall are not blocking the communication.<\/p>\n\n\n\n<p>See to configure firewall. I did a &#8220;dirty&#8221; stop.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><i># Stop iptables<\/i>\n\/etc\/init.d\/iptables stop\n\n<i># Set SELinux permissive<\/i>\nsetenforce 0\n<i># Note: To make SElinux changes permanent update \/etc\/sysconfig\/selinux.<\/i>\n<\/pre>\n\n\n\n<p><strong>&#8211; Restart xinetd<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@MySQL-Server nrpe-2.15]# \/etc\/init.d\/xinetd restart\nStopping xinetd:                                           [  OK  ]\nStarting xinetd:                                           [  OK  ]\n<\/pre>\n\n\n\n<p><strong>Configuration on Nagios Server:<\/strong><\/p>\n\n\n\n<p>&#8211; On <strong>Nagios Server<\/strong> add following to the hosts definition and update hostgroup to include another MySQL server:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define host{\nuse mysql-server\nhost_name mysqldb01\nalias MySQLServer\naddress 192.168.86.129\ncontact_groups admin\n}\n\ndefine hostgroup{\n        hostgroup_name mysql-servers\n        alias MySQL Servers\n<b>        members localhost, mysqldb01<\/b>\n}\n<\/pre>\n\n\n\n<p>&#8211; Restart nagios and all done!<\/p>\n\n\n\n<p>Hope that helps.<\/p>\n","protected":false},"excerpt":{"rendered":"We already have seen two articles for setting up MySQL Monitoring with Nagios and Percona Monitoring Tools for Nagios. Those posts covers configuration of nagios on single instance. Though following&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":[578,427,577,146],"class_list":{"0":"post-2296","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-tools","8":"category-mysql-articles","9":"tag-monitor-mysql-with-nagios","10":"tag-mysql","11":"tag-mysql-monitoring","12":"tag-nagios"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2296","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=2296"}],"version-history":[{"count":3,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2296\/revisions"}],"predecessor-version":[{"id":2875,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/2296\/revisions\/2875"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=2296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=2296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=2296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}