{"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[pastacode lang=\u201dsql\u201d manual=\u201dyum%20install%20httpd%0Ayum%20install%20gcc%0Ayum%20install%20glibc*%0Ayum%20install%20gd*%0A\u201d message=\u201dSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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[pastacode lang=\u201dsql\u201d manual=\u201duseradd%20nagios%0Apasswd%20nagios%0Agroupadd%20nagcmd%0Ausermod%20-G%20nagcmd%20nagios%0Ausermod%20-G%20nagcmd%20apache%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\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[pastacode lang=\u201dsql\u201d manual=\u201dmkdir%20NagiosSetup%0Acd%20NagiosSetup%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"download-nagios\"><span style=\"color: #993300;\"><b>Download <\/b><b>nagios:<\/b><\/span><\/h4>\n[pastacode lang=\u201dsql\u201d manual=\u201dwget%20-X%20Get%20%22http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnagios%2Ffiles%2Fnagios-3.x%2Fnagios-3.2.1%2Fnagios-3.2.1.tar.gz%2Fdownload%22%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"download-nagios-plugins\"><span style=\"color: #003300;\"><b>Download Nagios Plugins:<\/b><\/span><\/h4>\n[pastacode lang=\u201dsql\u201d manual=\u201dwget%20-X%20Get%20%22http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnagiosplug%2Ffiles%2Fnagiosplug%2F1.4.15%2Fnagios-plugins-1.4.15.tar.gz%2Fdownload%22\u2033 message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<p><label class=\"label label-success\"><span style=\"color: #008000;\"><strong>STEP 4:<\/strong><\/span>\u00a0<\/label>Install Nagios<\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dtar%20-xzvf%20nagios-3.2.1.tar.gz%0Acd%20nagios-3.2.1%0A.%2Fconfigure%20\u2013with-command-group%3Dnagcmd%0Amake%20all%0Amake%20install%0Amake%20install-config%0Amake%20install-commandmode%0Amake%20install-init%0Achkconfig%20\u2013add%20nagios%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p><span style=\"color: #993300;\"><b>Configure Nagios Web Interface:<\/b><\/span><\/p>\n[pastacode lang=\u201dsql\u201d manual=\u201dmake%20install-webconf%0Ahtpasswd%20-c%20%2Fusr%2Flocal%2Fnagios%2Fetc%2Fhtpasswd.users%20nagiosadmin%0A%5Bspecify%20password%20for%20nagios%20admin%5D%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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[pastacode lang=\u201dsql\u201d manual=\u201dtar%20xvf%20nagios-plugins-1.4.11.tar.gz%0Acd%20nagios-plugins-1.4.11%0A.%2Fconfigure%20\u2013with-nagios-user%3Dnagios%20\u2013with-nagios-group%3Dnagios%0Amake%0Amake%20install%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\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[pastacode lang=\u201dsql\u201d manual=\u201dservice%20nagios%20start%0ABrowse%3A%20http%3A%2F%2Flocalhost%2Fnagios%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<h4 id=\"here-if-you-get-error\"><span style=\"color: #003300;\">\u00a0Here if you get Error:<\/span><\/h4>\n[pastacode lang=\u201dsql\u201d manual=\u201d%E2%80%9CYou%20don%E2%80%99t%20have%20permission%20to%20access%20%2Fnagios%2F%20on%20this%20server.%E2%80%9D%0A%0ACheck%20%2Fetc%2Fhttpd%2Fconf%2Fhttpd.conf%20for%20DirectoryIndex.%0AIf%20it%E2%80%99s%20not%20having%20index.php%20add%20it%20as%20follows%3A%0A%0Avi%20%2Fetc%2Fhttpd%2Fconf%2Fhttpd.conf%0ADirectoryIndex%20index.php%20index.html%20index.html.var%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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[pastacode lang=\u201dsql\u201d manual=\u201dwget%20http%3A%2F%2Flabs.consol.de%2Fwp-content%2Fuploads%2F2010%2F10%2Fcheck_mysql_health-2.1.3.tar.gz%0A%0Atar%20-zxvf%20check_mysql_health-2.1.3.tar.gz%0Acd%20check_mysql_health-2.1.3%0A.%2Fconfigure%20\u2013prefix%3D%2Fusr%2Flocal%2Fnagios%20\u2013with-nagios-user%3Dnagios%20\u2013with-nagios-group%3Dnagios%20\u2013with-perl%3D%2Fusr%2Fbin%2Fperl%0Amake%0Amake%20install%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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 \u2018nagios\u2019@\u2019localhost\u2019 identified by \u2018nagios\u2019;<\/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[pastacode lang=\u201dsql\u201d manual=\u201d%5BChange%20contacts.cfg%20file%20accordingly.%5D%0Avi%20%2Fusr%2Flocal%2Fnagios%2Fetc%2Fobjects%2Fcontacts.cfg%0A%0Adefine%20contact%0A%7B%0Acontact_name%20nagiosadmin%20%3B%20Short%20name%20of%20user%0Ause%20generic-contact%20%3B%20Inherit%20default%20values%20from%20generic-contact%20template%20(defined%20above)%0Aalias%20Kedar%20%3B%20Full%20name%20of%20user%0Aemail%20kedar%40nitty-witty.com%20%3B%20%3C%3C*****%20CHANGE%20THIS%20TO%20YOUR%20EMAIL%20ADDRESS%20******%0A%7D%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\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[pastacode lang=\u201dsql\u201d manual=\u201dvi%20%2Fusr%2Flocal%2Fnagios%2Fetc%2Fnagios.cfg%20%0Aadd%20following%20line%3A%0Acfg_file%3D%2Fusr%2Flocal%2Fnagios%2Fetc%2Fobjects%2Fmysqlmonitoring.cfg%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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[pastacode lang=\u201dsql\u201d manual=\u201dvi%20%2Fusr%2Flocal%2Fnagios%2Fetc%2Fobjects%2Fcommands.cfg%0A%0Adefine%20command%0A%7B%0Acommand_name%20check_mysql_health%0Acommand_line%20%24USER1%24%2Fcheck_mysql_health%20-H%20%24ARG4%24%20\u2013username%20%24ARG1%24%20\u2013password%20%24ARG2%24%20\u2013port%20%24ARG5%24%20\u2013mode%20%24ARG3%24%0A%7D%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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[pastacode lang=\u201dsql\u201d manual=\u201dvi%20%2Fusr%2Flocal%2Fnagios%2Fetc%2Fobjects%2Fmysqlmonitoring.cfg%0AAdd%3A%0A%0Adefine%20service%0A%7B%0Ause%20local-service%0Ahost_name%20localhost%0Aservice_description%20MySQL%20connection-time%0Acheck_command%20check_mysql_health!nagios!nagios!connection-time!127.0.0.1!3306!%0A%7D%0Adefine%20service%7B%0Ause%20local-service%0Ahost_name%20localhost%0Aservice_description%20MySQL%20slave-io-running%0Acheck_command%20check_mysql_health!nagios!nagios!slave-io-running!127.0.0.1!3306!%0A%7D%0A%0Adefine%20service%7B%0Ause%20local-service%0Ahost_name%20localhost%0Aservice_description%20MySQL%20slave-sql-running%0Acheck_command%20check_mysql_health!nagios!nagios!slave-sql-running!127.0.0.1!3306!%0A%7D%0A\u201d message=\u201dMYSQL CODE\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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 \u201ccompile\u201d 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 \u2018\/usr\/local\/nagios\u2019)<\/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 \u2018nagios\u2019)<\/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 \u2018nagios\u2019)<\/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=\u201dbanner\u201d]\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 \u201c<strong>check_mssql_health<\/strong>\u201d script.<\/li>\n<li>You will also find a <strong>\u201ccheck_mssql_health.pl<\/strong>\u201d 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>\u2018libexec\/\u2019 subdirectory<\/strong> in the base directory you specified with\u00a0the \u2013prefix 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>\u00a0<\/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}]}}