{"id":3653,"date":"2017-04-03T13:07:46","date_gmt":"2017-04-03T07:37:46","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=3653"},"modified":"2018-10-27T11:44:56","modified_gmt":"2018-10-27T06:14:56","slug":"how-to-install-check_mysql_health-plugin-nagios","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/how-to-install-check_mysql_health-plugin-nagios\/","title":{"rendered":"How to install check_mysql_health plugin in nagios"},"content":{"rendered":"<p>This post guides you to install <strong>check_mysql_health plugin<\/strong> in nagios. So, first we have to install and configure Nagios. Follow the steps as below:<\/p>\n<h4 id=\"installing-and-configuring-nagios\"><span style=\"color: #993300;\"><b>Installing and configuring Nagios:<\/b><\/span><\/h4>\n<p><strong><label class=\"label label-success\"><span style=\"color: #008000;\">STEP 1:<\/span>\u00a0<\/label><\/strong>Install required stuff:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">SQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">yum install httpd<br\/>yum install gcc<br\/>yum install glibc*<br\/>yum install gd*<\/code><\/pre> <\/div>\n<p><strong><span style=\"color: #008000;\"><label class=\"label label-success\">STEP 2:\u00a0<\/label><\/span><\/strong>Create Nagios user account and group:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">useradd nagios<br\/>passwd nagios<br\/>groupadd nagcmd<br\/>usermod -G nagcmd nagios<br\/>usermod -G nagcmd apache<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<label class=\"label label-success\"><span style=\"color: #008000;\"><strong>STEP 3:<\/strong><\/span>\u00a0<\/label>Downloads:<\/p>\n<h4 id=\"create-directory\"><span style=\"color: #ff6600;\"><b>Create directory:<\/b><\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">mkdir NagiosSetup<br\/>cd NagiosSetup<\/code><\/pre> <\/div>\n<h4 id=\"download-nagios\"><span style=\"color: #993300;\"><b>Download <\/b><b>nagios:<\/b><\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">wget -X Get &quot;http:\/\/sourceforge.net\/projects\/nagios\/files\/nagios-3.x\/nagios-3.2.1\/nagios-3.2.1.tar.gz\/download&quot;<\/code><\/pre> <\/div>\n<h4 id=\"download-nagios-plugins\"><span style=\"color: #003300;\"><b>Download Nagios Plugins:<\/b><\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">wget -X Get &quot;http:\/\/sourceforge.net\/projects\/nagiosplug\/files\/nagiosplug\/1.4.15\/nagios-plugins-1.4.15.tar.gz\/download&quot;<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p><label class=\"label label-success\"><span style=\"color: #008000;\"><strong>STEP 4:<\/strong><\/span>\u00a0<\/label>Install Nagios<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">tar -xzvf nagios-3.2.1.tar.gz<br\/>cd nagios-3.2.1<br\/>.\/configure --with-command-group=nagcmd<br\/>make all<br\/>make install<br\/>make install-config<br\/>make install-commandmode<br\/>make install-init<br\/>chkconfig --add nagios<\/code><\/pre> <\/div>\n<p><span style=\"color: #993300;\"><b>Configure Nagios Web Interface:<\/b><\/span><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">make install-webconf<br\/>htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<br\/>[specify password for nagios admin]<\/code><\/pre> <\/div>\n<p><span style=\"color: #008000;\"><label class=\"label label-success\"><strong>STEP 5:<\/strong> <\/label><\/span>Install <a href=\"https:\/\/www.wikitechy.com\/step-by-step-tutorials\/wordpress\/wordpress-installed-plugins\" target=\"_blank\" rel=\"noopener\">plugins<\/a><\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">tar xvf nagios-plugins-1.4.11.tar.gz<br\/>cd nagios-plugins-1.4.11<br\/>.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<br\/>make<br\/>make install<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p><label class=\"label label-success\"><span style=\"color: #008000;\"><strong>STEP 6:<\/strong><\/span>\u00a0<\/label>Verify Installation, Starting nagios for the first time<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">service nagios start<br\/>Browse: http:\/\/localhost\/nagios<\/code><\/pre> <\/div>\n<h4 id=\"here-if-you-get-error\"><span style=\"color: #003300;\">\u00a0Here if you get Error:<\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">\u201cYou don\u2019t have permission to access \/nagios\/ on this server.\u201d<br\/><br\/>Check \/etc\/httpd\/conf\/httpd.conf for DirectoryIndex.<br\/>If it\u2019s not having index.php add it as follows:<br\/><br\/>vi \/etc\/httpd\/conf\/httpd.conf<br\/>DirectoryIndex index.php index.html index.html.var<\/code><\/pre> <\/div>\n<ul>\n<li>Make sure you do restart<strong> apache(httpd)<\/strong> and nagios every time you change the config file. You must have <a href=\"https:\/\/www.wikitechy.com\/php\/\" target=\"_blank\" rel=\"noopener\">php<\/a> installed<\/li>\n<\/ul>\n<h4 id=\"monitoring-mysql\"><span style=\"color: #993300;\"><b>Monitoring MySQL:<\/b><\/span><\/h4>\n<p><span style=\"color: #008000;\"><strong><label class=\"label label-success\">STEP 7:\u00a0<\/label><\/strong><\/span>Download, Extract and install the <a href=\"https:\/\/www.wikitechy.com\/tutorials\/sql\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a> Plugin:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">wget http:\/\/labs.consol.de\/wp-content\/uploads\/2010\/10\/check_mysql_health-2.1.3.tar.gz<br\/><br\/>tar -zxvf check_mysql_health-2.1.3.tar.gz<br\/>cd check_mysql_health-2.1.3<br\/>.\/configure --prefix=\/usr\/local\/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=\/usr\/bin\/perl<br\/>make<br\/>make install<\/code><\/pre> <\/div>\n<p><span style=\"color: #008000;\"><strong><label class=\"label label-success\">STEP 8:\u00a0<\/label><\/strong><\/span><a href=\"https:\/\/www.wikitechy.com\/tutorials\/sql\/create-database\" target=\"_blank\" rel=\"noopener\">Create database<\/a> user:<\/p>\n<p>grant usage, replication client on *.* to &#8216;nagios&#8217;@&#8217;localhost&#8217; identified by &#8216;nagios&#8217;;<\/p>\n<p><label class=\"label label-success\"><span style=\"color: #008000;\"><strong>STEP 9:<\/strong><\/span>\u00a0<\/label>Provide email address for nagiosadmin:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">[Change contacts.cfg file accordingly.]<br\/>vi \/usr\/local\/nagios\/etc\/objects\/contacts.cfg<br\/><br\/>define contact<br\/>{<br\/>contact_name nagiosadmin ; Short name of user<br\/>use generic-contact ; Inherit default values from generic-contact template (defined above)<br\/>alias Kedar ; Full name of user<br\/>email kedar@nitty-witty.com ; &lt;&lt;***** CHANGE THIS TO YOUR EMAIL ADDRESS ******<br\/>}<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p><span style=\"color: #008000;\"><strong><label class=\"label label-success\">STEP 10:\u00a0<\/label><\/strong><\/span>Configuring Nagios to Monitor MySQL Server<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">vi \/usr\/local\/nagios\/etc\/nagios.cfg <br\/>add following line:<br\/>cfg_file=\/usr\/local\/nagios\/etc\/objects\/mysqlmonitoring.cfg<\/code><\/pre> <\/div>\n<h4 id=\"define-check_mysql_health-command-as-follows\"><span style=\"color: #993300;\"><b>Define <\/b><b>check_mysql_health<\/b><b> command as follows:<\/b><\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">vi \/usr\/local\/nagios\/etc\/objects\/commands.cfg<br\/><br\/>define command<br\/>{<br\/>command_name check_mysql_health<br\/>command_line $USER1$\/check_mysql_health -H $ARG4$ --username $ARG1$ --password $ARG2$ --port $ARG5$ --mode $ARG3$<br\/>}<\/code><\/pre> <\/div>\n<h4 id=\"enter-services-to-be-monitored-in-mysqlmonitoring-cfg\"><span style=\"color: #ff6600;\"><b>Enter services to be monitored in <\/b><b>mysqlmonitoring.cfg<\/b>:<\/span><\/h4>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">MYSQL CODE<\/span> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">vi \/usr\/local\/nagios\/etc\/objects\/mysqlmonitoring.cfg<br\/>Add:<br\/><br\/>define service<br\/>{<br\/>use local-service<br\/>host_name localhost<br\/>service_description MySQL connection-time<br\/>check_command check_mysql_health!nagios!nagios!connection-time!127.0.0.1!3306!<br\/>}<br\/>define service{<br\/>use local-service<br\/>host_name localhost<br\/>service_description MySQL slave-io-running<br\/>check_command check_mysql_health!nagios!nagios!slave-io-running!127.0.0.1!3306!<br\/>}<br\/><br\/>define service{<br\/>use local-service<br\/>host_name localhost<br\/>service_description MySQL slave-sql-running<br\/>check_command check_mysql_health!nagios!nagios!slave-sql-running!127.0.0.1!3306!<br\/>}<\/code><\/pre> <\/div>\n<p><span style=\"color: #800000;\"><strong>Note:<\/strong> <\/span>Every time you change configuration file, verify before starting nagios using command:<\/p>\n<p><code>\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>Finally <strong>start nagios service<\/strong> and you\u2019re done with nagios installation and configuration for monitoring MySQL.<\/p>\n<h4 id=\"how-to-compile-the-check_mysql_health-script\"><span style=\"color: #003300;\"><b>How to &#8220;compile&#8221; the <\/b><b>check_mysql_health<\/b><b> script:<\/b><\/span><\/h4>\n<ul>\n<li>Run the configure script to initialize variables and create a<strong> Makefile<\/strong>, etc.<\/li>\n<\/ul>\n<pre>.\/configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP\r\n--with-perl=PATH_TO_PERL --with-statefiles-dir=STATE_PATH<\/pre>\n<ul>\n<li>Replace <strong>BASEDIRECTORY<\/strong> with the path of the directory under which Nagios<\/li>\n<\/ul>\n<p>is installed (default is &#8216;\/usr\/local\/nagios&#8217;)<\/p>\n<ul>\n<li>\u00a0Replace <strong>SOMEUSER<\/strong> with the name of a user on your system that will be<\/li>\n<\/ul>\n<p>assigned permissions to the installed plugins (default is &#8216;nagios&#8217;)<\/p>\n<ul>\n<li>\u00a0Replace <strong>SOMEGRP<\/strong> with the name of a group on your system that will be<\/li>\n<\/ul>\n<p>assigned permissions to the installed plugins (default is &#8216;nagios&#8217;)<\/p>\n<ul>\n<li>\u00a0Replace <strong>PATH_TO_PERL<\/strong> with the path where a perl binary can be found.<\/li>\n<\/ul>\n<p>Besides the system wide perl you might have installed a private perl<\/p>\n<p>just for the nagios plugins (default is the perl in your path).<\/p>\n<ul>\n<li>\u00a0Replace <strong>STATE_PATH<\/strong> with the directory where you want the script to<\/li>\n<\/ul>\n<p>write state files which transport information from one run to the next.<\/p>\n<p>(default is \/tmp)<\/p>\n<p>Simply <strong>running .\/configure<\/strong> will be sufficient to create a check_mssql_health\u00a0script which you can customize later.<\/p>\n[ad type=&#8221;banner&#8221;]\n<h3 id=\"compile-the-plugin-with-the-following-command\"><span style=\"color: #ff6600;\"><b>Compile the plugin with the following command:<\/b><\/span><\/h3>\n<p><code>make<\/code><\/p>\n<ul>\n<li>This will produce a &#8220;<strong>check_mssql_health<\/strong>&#8221; script.<\/li>\n<li>You will also find a <strong>&#8220;check_mssql_health.pl<\/strong>&#8221; which you better ignore.<\/li>\n<li>It is the base for the <strong>compilation<\/strong> filled with placeholders.<\/li>\n<li>These will be <strong>replaced<\/strong> during the make process.<\/li>\n<\/ul>\n<h3 id=\"install-the-compiled-plugin-script-with-the-following-command\"><span style=\"color: #993300;\"><b>Install the compiled plugin script with the following command<\/b>:<\/span><\/h3>\n<p><code>make install<\/code><\/p>\n<ul>\n<li>The installation procedure will attempt to place the plugin in a\u00a0 <strong>&#8216;libexec\/&#8217; subdirectory<\/strong> in the base directory you specified with\u00a0the &#8211;prefix argument to the configure script.<\/li>\n<li>Verify that your configuration files for Nagios contains the correct paths to the new plugin.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to install check_mysql_health plugin in nagios &#8211; &#8220;check_mssql_health&#8221; script.You will find a &#8220;check_mssql_health.pl&#8221; which you better ignore.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1699,27],"tags":[6969,6968,6975,6976,6974,6967,6971,6970,6972,6973,6979,6982,6978,6980,6981,6977],"class_list":["post-3653","post","type-post","status-publish","format-standard","hentry","category-linux","category-mysql","tag-check_mysql-nagios-plugin-download","tag-how-to-monitor-mysql-using-nagios","tag-how-to-use-nagios-plugin","tag-how-to-use-nagios-plugins-in-verax-nms","tag-mysql-health-check-script","tag-nagios-check_mysql-example","tag-nagios-core-mysql","tag-nagios-mysql-backend","tag-nagios-mysql-database","tag-nagios-mysql-query","tag-nagios-plugins-directory","tag-nagios-plugins-documentation","tag-nagios-plugins-download-for-linux","tag-nagios-plugins-list","tag-nagios-plugins-tutorial","tag-re-use-nagios-plugins-in-sensu-for-quick-profit"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/3653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=3653"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/3653\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=3653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=3653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=3653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}