This post guides you to install check_mysql_health plugin in nagios. So, first we have to install and configure Nagios. Follow the steps as below:
Installing and configuring Nagios:
Install required stuff:
Create Nagios user account and group:
[ad type=”banner”] Downloads:Create directory:
Download nagios:
Download Nagios Plugins:
[ad type=”banner”]Install Nagios
Configure Nagios Web Interface:
Install plugins
[ad type=”banner”]Verify Installation, Starting nagios for the first time
Here if you get Error:
- Make sure you do restart apache(httpd) and nagios every time you change the config file. You must have php installed
Monitoring MySQL:
Download, Extract and install the MySQL Plugin:
Create database user:
grant usage, replication client on *.* to ‘nagios’@’localhost’ identified by ‘nagios’;
Provide email address for nagiosadmin:
[ad type=”banner”]Configuring Nagios to Monitor MySQL Server
Define check_mysql_health command as follows:
Enter services to be monitored in mysqlmonitoring.cfg:
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.
How to “compile” the check_mysql_health script:
- Run the configure script to initialize variables and create a Makefile, etc.
./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-statefiles-dir=STATE_PATH
- Replace BASEDIRECTORY with the path of the directory under which Nagios
is installed (default is ‘/usr/local/nagios’)
- Replace SOMEUSER with the name of a user on your system that will be
assigned permissions to the installed plugins (default is ‘nagios’)
- Replace SOMEGRP with the name of a group on your system that will be
assigned permissions to the installed plugins (default is ‘nagios’)
- Replace PATH_TO_PERL with the path where a perl binary can be found.
Besides the system wide perl you might have installed a private perl
just for the nagios plugins (default is the perl in your path).
- Replace STATE_PATH with the directory where you want the script to
write state files which transport information from one run to the next.
(default is /tmp)
Simply running ./configure will be sufficient to create a check_mssql_health script which you can customize later.
[ad type=”banner”]Compile the plugin with the following command:
make
- This will produce a “check_mssql_health” script.
- You will also find a “check_mssql_health.pl” which you better ignore.
- It is the base for the compilation filled with placeholders.
- These will be replaced during the make process.
Install the compiled plugin script with the following command:
make install
- The installation procedure will attempt to place the plugin in a ‘libexec/’ subdirectory in the base directory you specified with the –prefix argument to the configure script.
- Verify that your configuration files for Nagios contains the correct paths to the new plugin.