Thursday, June 9, 2011

Adding Windows machines to Nagios

Adding Windows machines to Nagios
Nagios is an open source powerful monitoring system that enables you to monitor your servers, services, application and so on. It has also ability to monitor Windows based servers, but in order to communicate with Windows servers, you should install Nagios agent on each machine. I am going to explain that how to configure the Nagios for Windows machine and also how to install Nagios Client agent on the Windows machine.
Here is the general idea:
Nagios(Monitoring Server(Linux)) -----àcheck_nt ---------------àNSClient++ ----àCPU
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àMemory
Nagios (Monitoring Server(Linux)) ----àcheck_nt ---------------àNSClient++ ----àDisk Space
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àProcesses
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àServices

Configure Nagios:
1.       Login as su (Super User)
2.       vi /usr/local/nagios/etc/nagios.cfg
3.       remove (#) sign from the following line:
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Save the file and exit.
4.       Go to /usr/local/nagios/etc/objects/ directory.(cd /usr/local/nagios/etc/objects)
5.       Edit windows.cfg (vi windows.cfg)
6.       Under Host Group Definitions, define a hostgroup for windows machines. An example can be like this:
define hostgroup{
                hostgroup_name             myWindows
                alias                                       Windows Machines
                }
7.       Under Service Definitions, create services for Uptime of the server, CPU load, Memory Usage, and C:\ disk usage like this:
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        Uptime
                check_command             check_nt!UPTIME
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        CPU Load
                check_command             check_nt!CPULOAD!-l 5,85,95
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        Memory Usage
                check_command             check_nt!MEMUSE!-w 90 –c 95
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        C:\ Drive Space
                check_command             check_nt!USEDDISKSPACE!-l c -w 85 –c 95
                }

which –w means Warning and –c means Critical.
8.       Now, you should define your hosts for windows machines that we are going to monitor, something like this for each host:

Define host{
                use                         myWindows
                host_name         xxxxxxxx
                alias                       yyyyyyy
                address                                xxxxxxxx.xxx.xxx
                }
Replace  xxxxxxxx with actual hostname and yyyyyyy with a longer name associated with the host and xxxxxxx.xxx.xxx with fully qualified name of host.

9.       Test nagios configuration   with this command:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You should see these lines from the output:
Total Warnings: 0
Total Errors:   0
If you see any error, check your configuration file.
10.   Restart Nagios:  restart nagios service

Nagios agent for Windows OS(NSCLIENT++):
Nsclient++ is a secure monitoring daemon for Windows OS. Nsclient++ has to install in Windows machine in order to talk with Linux machine and nagios. You can download the latest version(msi) of nsclinet++ from this link:  http://nsclient.org/nscp/downloads
Run installation and put the fully qualified name of the Windows machine into the Allowed Hosts and then check all options and don’t check the NSCA if you are not sure. At the end, check Start Services.
Regards,
Khosro Taraghi

1 comment:

  1. Thanks for great information you write it very clean. thanks for sharing with us. NDT Machine

    ReplyDelete