Mysql Monitoring Nagios
Mysql Monitoring Nagios
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. Lets unleash the power step by step:
Step-3: Downloads:
Create directory: mkdir NagiosSetup cd NagiosSetup
Download nagios
wget -X Get "http://sourceforge.net/projects/nagios/files/nagios3.x/nagios-3.2.1/nagios-3.2.1.tar.gz/download"
http://kedar.nitty-witty.com/blog
[If you miss step "make install-init" you may get:: error reading information on service nagios: No such file or directory ] Configure Nagios Web Interface:
make install-webconf htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Browse: http://localhost/nagios Here if you get Error: You dont have permission to access /nagios/ on this server. Check /etc/httpd/conf/httpd.conf for DirectoryIndex. If its not having index.php add it as follows:
vi /etc/httpd/conf/httpd.conf DirectoryIndex index.php index.html index.html.var
Make sure you do restart apache(httpd) and nagios every time you change the config file. You must have php installed.
Monitoring MySQL:
Step-7: Download, Extract and install the MySQL Plugin:
wget http://labs.consol.de/wpcontent/uploads/2010/10/check_mysql_health-2.1.3.tar.gz tar -zxvf check_mysql_health-2.1.3.tar.gz cd check_mysql_health-2.1.3 ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios -with-nagios-group=nagios --with-perl=/usr/bin/perl make make install
http://kedar.nitty-witty.com/blog
Step-9: Provide email address for nagiosadmin: [Change contacts.cfg file accordingly.]
vi /usr/local/nagios/etc/objects/contacts.cfg define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Kedar ; Full name of user email kedar@nitty-witty.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }
Add:
define service{ use local-service host_name localhost service_description MySQL connection-time check_command check_mysql_health!nagios!nagios!connectiontime!127.0.0.1!3306! } define service{ use local-service host_name localhost service_description MySQL slave-io-running check_command check_mysql_health!nagios!nagios!slave-iorunning!127.0.0.1!3306! }
http://kedar.nitty-witty.com/blog
define service{ use local-service host_name localhost service_description MySQL slave-sql-running check_command check_mysql_health!nagios!nagios!slave-sqlrunning!127.0.0.1!3306! }
Here we'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/ Note: Every time you change configuration file, verify before starting nagios using command:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Finally start nagios service and you're done with nagios installation and configuration for monitoring MySQL. I hope you've found this useful.
http://kedar.nitty-witty.com/blog