{"id":1348,"date":"2010-11-18T10:42:52","date_gmt":"2010-11-18T10:42:52","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=1348"},"modified":"2016-08-22T15:32:51","modified_gmt":"2016-08-22T15:32:51","slug":"10-steps-mysql-monitoring-nagios-installation-configuration","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/10-steps-mysql-monitoring-nagios-installation-configuration","title":{"rendered":"10 Steps: MySQL Monitoring through Nagios: Install &#038; Configure"},"content":{"rendered":"<p>Nagios is a powerful monitoring system and here we will learn how to monitor MySQL through Nagios. We will be installing Nagios, required plugins and configuring it to monitor MySQL Database Server.<\/p>\n<p>Let&#8217;s unleash the power step by step:<\/p>\n<h2>Installing and configuring Nagios<\/h2>\n<p><strong>Step-1 : Install required stuff:<\/strong><br \/>\n<code>yum install httpd<br \/>\nyum install gcc<br \/>\nyum install glibc*<br \/>\nyum install gd*<\/code><\/p>\n<p><strong>Step-2 :Create Nagios user account and group<\/strong><br \/>\n<code>useradd nagios<br \/>\npasswd nagios<br \/>\ngroupadd nagcmd<br \/>\nusermod -G nagcmd nagios<br \/>\nusermod -G nagcmd apache<\/code><\/p>\n<p><strong>Step-3: Downloads:<\/strong><br \/>\n<code>Create directory:<br \/>\nmkdir NagiosSetup<br \/>\ncd NagiosSetup<\/code><\/p>\n<p>Download nagios<br \/>\n<code>wget -X Get \"http:\/\/sourceforge.net\/projects\/nagios\/files\/nagios-3.x\/nagios-3.2.1\/nagios-3.2.1.tar.gz\/download\"<\/code><\/p>\n<p>Download Nagios Plugins:<br \/>\n<code>wget -X Get \"http:\/\/sourceforge.net\/projects\/nagiosplug\/files\/nagiosplug\/1.4.15\/nagios-plugins-1.4.15.tar.gz\/download\"<\/code><\/p>\n<blockquote style=\"background-color:yellow\"><p><small> <b>Follow up articles:<\/b><br \/>\n<span style=\"color: #0000ff;\"><strong> 1<\/strong><\/span>: <a href=\"http:\/\/kedar.nitty-witty.com\/install-percona-monitoring-tools-for-nagios-mysql-plugins\" target=_blank rel=\"nofollow\">Installing Percona Monitoring Tools for MySQL Nagios<\/a>.<br \/>\n<span style=\"color: #0000ff;\"><strong> 2<\/strong><\/span>: <a href=\"http:\/\/kedar.nitty-witty.com\/how-to-add-remote-mysql-server-to-nagios-monitoring\" target=_blank rel=\"nofollow\">Adding remote MySQL Host to Nagios Setup<\/a>.<\/small>\n<\/p><\/blockquote>\n<p><strong>Step-4: Install Nagios<\/strong><\/p>\n<p><code>tar -xzvf nagios-3.2.1.tar.gz<br \/>\ncd nagios-3.2.1<br \/>\n.\/configure --with-command-group=nagcmd<br \/>\nmake all<br \/>\nmake install<br \/>\nmake install-config<br \/>\nmake install-commandmode<br \/>\nmake install-init<br \/>\nchkconfig --add nagios<\/code><\/p>\n<p>[If you miss step &#8220;make install-init&#8221; you may get:: error reading information on service nagios: No such file or directory ]<\/p>\n<p><span style=\"text-decoration: underline;\">Configure Nagios Web Interface:<\/span><br \/>\n<code>make install-webconf<br \/>\nhtpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<\/code><br \/>\n[specify password for nagios admin]<\/p>\n<p><strong>Step-5: Install plugins<\/strong><br \/>\n<code>tar xvf nagios-plugins-1.4.11.tar.gz<br \/>\ncd nagios-plugins-1.4.11<br \/>\n.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<br \/>\nmake<br \/>\nmake install<\/code><\/p>\n<p><strong>Step-6: Verify Installation, Starting nagios for the first time<\/strong><\/p>\n<p><code>service nagios start<\/code><br \/>\nBrowse: http:\/\/localhost\/nagios<\/p>\n<p><strong><em>Here if you get Error:<\/em> <\/strong><br \/>\n<span style=\"text-decoration: underline;\">&#8220;You don&#8217;t have permission to access \/nagios\/ on this server.&#8221;<\/span><\/p>\n<p>Check \/etc\/httpd\/conf\/httpd.conf for DirectoryIndex.<br \/>\nIf it&#8217;s not having index.php add it as follows:<\/p>\n<p><code>vi \/etc\/httpd\/conf\/httpd.conf<br \/>\nDirectoryIndex index.php index.html index.html.var<\/code><\/p>\n<p>Make sure you do restart apache(httpd) and nagios every time you change the config file. You must have php installed.<\/p>\n<h2>Monitoring MySQL:<\/h2>\n<p><strong>Step-7: Download, Extract and install the MySQL Plugin:<\/strong><\/p>\n<p><code>wget http:\/\/labs.consol.de\/wp-content\/uploads\/2010\/10\/check_mysql_health-2.1.3.tar.gz<\/code><\/p>\n<p><code>tar -zxvf check_mysql_health-2.1.3.tar.gz<br \/>\ncd check_mysql_health-2.1.3<br \/>\n.\/configure --prefix=\/usr\/local\/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=\/usr\/bin\/perl<br \/>\nmake<br \/>\nmake install<\/code><\/p>\n<p><strong>Step-8: Create database user:<\/strong><br \/>\n<code>grant usage, replication client on *.* to 'nagios'@'localhost' identified by 'nagios';<\/code><\/p>\n<p><strong>Step-9: Provide email address for nagiosadmin:<\/strong><br \/>\n[Change contacts.cfg file accordingly.]<br \/>\n<code>vi \/usr\/local\/nagios\/etc\/objects\/contacts.cfg<\/code><br \/>\n<code><br \/>\ndefine contact{<br \/>\ncontact_name nagiosadmin ; Short name of user<br \/>\nuse generic-contact ; Inherit default values from generic-contact template (defined above)<br \/>\nalias Kedar ; Full name of user<br \/>\nemail kedar@nitty-witty.com ; &lt;&lt;***** CHANGE THIS TO YOUR EMAIL ADDRESS ******<br \/>\n}<\/code><\/p>\n<p><strong>Step-10: Configuring Nagios to Monitor MySQL Server<\/strong><\/p>\n<p><code>vi \/usr\/local\/nagios\/etc\/nagios.cfg <\/code><br \/>\nadd following line:<br \/>\n<code>cfg_file=\/usr\/local\/nagios\/etc\/objects\/mysqlmonitoring.cfg<\/code><\/p>\n<p>Define check_mysql_health command as follows:<\/p>\n<p><code>vi \/usr\/local\/nagios\/etc\/objects\/commands.cfg<\/code><\/p>\n<p><code>define command{<br \/>\ncommand_name check_mysql_health<br \/>\ncommand_line $USER1$\/check_mysql_health -H $ARG4$ --username $ARG1$ --password $ARG2$ --port $ARG5$ --mode $ARG3$<br \/>\n}<\/code><\/p>\n<p>Enter services to be monitored in mysqlmonitoring.cfg:<\/p>\n<p><code>vi \/usr\/local\/nagios\/etc\/objects\/mysqlmonitoring.cfg<\/code><br \/>\nAdd:<\/p>\n<p><code>define service{<br \/>\nuse local-service<br \/>\nhost_name localhost<br \/>\nservice_description MySQL connection-time<br \/>\ncheck_command check_mysql_health!nagios!nagios!connection-time!127.0.0.1!3306!<br \/>\n}<\/code><br \/>\n<code><br \/>\ndefine service{<br \/>\nuse local-service<br \/>\nhost_name localhost<br \/>\nservice_description MySQL slave-io-running<br \/>\ncheck_command check_mysql_health!nagios!nagios!slave-io-running!127.0.0.1!3306!<br \/>\n}<\/code><br \/>\n<code><br \/>\ndefine service{<br \/>\nuse local-service<br \/>\nhost_name localhost<br \/>\nservice_description MySQL slave-sql-running<br \/>\ncheck_command check_mysql_health!nagios!nagios!slave-sql-running!127.0.0.1!3306!<br \/>\n}<\/code><\/p>\n<p>Here we&#8217;ve monitored 3 services: Connection-time, io thread and sql thread (replication) status. You can monitor more parameters described here: http:\/\/labs.consol.de\/nagios\/check_mysql_health\/<\/p>\n<p>Note: Every time you change configuration file, verify before starting nagios using command:<br \/>\n<code>\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>Finally start nagios service and you&#8217;re done with nagios installation and configuration for monitoring MySQL.<\/p>\n<h3><a href=\"http:\/\/kedar.nitty-witty.com\/wp-content\/uploads\/2010\/11\/10-steps-mysql-monitoring-nagios-install-configure.pdf\" target=\"_blank\"> Download PDF<\/a><\/h3>\n<p>I hope you&#8217;ve found this useful.<\/p>\n","protected":false},"excerpt":{"rendered":"Nagios is a powerful monitoring system and here we will learn how to monitor MySQL through Nagios. We will be installing Nagios, required plugins and configuring it to monitor MySQL&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,377,6],"tags":[147,224,142,427,146],"class_list":{"0":"post-1348","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-articles","8":"category-technical","9":"tag-database-monitoring","10":"tag-install-nagio-step-by-step","11":"tag-installation","12":"tag-mysql","13":"tag-nagios"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1348","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=1348"}],"version-history":[{"count":27,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1348\/revisions"}],"predecessor-version":[{"id":2388,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/1348\/revisions\/2388"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=1348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=1348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=1348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}