Monday 21 February 2011

Nagios on Linux to monitor MS SQL

how to use Systems in a heterogeneous computing environment ; here We look at using the Open Source Tool, Nagios, to monitor port 1422 on a Microsoft SQL Server.

Nagios

Nagios is an Open Source monitoring tool that can create alerts and reports for availability of your Network Services. Most Linux distributions include this valuable tool and we will look it on SUSE Enterprise Linux 11. It has a web front-end that is provided by the ubiquitous Apache Server, so a working knowledge of Apache is always useful.

Install Nagios

Nagios uses a web from end provided by apache and I have that already installed on my server as we can see through:
zypper se apache
We will install Nagios and its’ plugins from out standard repository
zypper -n in nagios nagios-plugins
During the installation a configuration file is added to /etc/apache2/conf.d. This allows the /nagios alias to be used to access the web page on your site and sets up security for the Nagios website.
The zypper tool was provided in SUSE from 10.1 onwards and searches installation repositories from the command line interface for the required software and dependencies.

Configure Nagios and Apache

From the apache configuration, /etc/apache2/conf.d/nagios, we see that http file authentication is used to a file called: /etc/nagios/htpasswd.users. This does not exist and needs to be created with a user called “nagiosadmin“.
htpasswd2 -c /etc/nagios/htpasswd.users nagiosadmin
Now you restart the Apache Server:
rcpache2 restart

Configure Nagios

I will demonstrate using the standard template: /etc/nagios/objects/windows.cfg
This is commented from the man nagios file, /etc/nagios/nagios.cfg, so all we need to firstly, uncomment the line in the nagios.cfg file and then edit the windows.cfg file to suits out needs. As I only need to poll the TCP Port 1433, I do not need to install the Nagios Client on the Windows box. I just need the windows.cfg file to read similar to this:
define host{
use                    windows-server
host_name              da-ad
alias                  SQL Server
address                172.17.0.11

}
define service{
use                    generic-service
host_name              da-ad
service_description    SQL port Check
check_command         check_tcp!1433
}

Now we are ready to test Nagios. First we should check our configuration using the aptly named “pre-flight check”.
nagios -v /etc/nagios/nagios/nagios.cfg
If that is Ok then start Nagios:
rcnagios start.

View Nagios

Now from your bowser you are ready to view the website at http://localhost/nagios and authenticating at nagiosadmin, the user we created earlier for apache.
nagios

No comments: