About Me

My photo
Kalyan Kumar Pasupuleti B-Tech(Information Technology). • AWS Certified Solutions Architect - Associate • RedHat Certified Engineer(RHCE) • Directory Services and Authentication Certificate of Expertise(LDAP) • Red Hat SELinux Policy Administration Certificate of Expertise(SELinux) • Network Services Security Certificate of Expertise (Network Services) • RedHat Certified Virtualization Administrator(RHCVA) • Red Hat Certified Security Specialist (RHCSS) Working as Cloud DevOps engineer

Sunday, March 3, 2013

Monitoring Windows Machines using Nagios


This article describes how you can monitor "private" services and attributes of Windows machines like:
  • CPU load
  • Disk usage
  • Memory usage
  • Service states
  • Running processes, etc …
Monitoring private services or attributes of a Windows machine requires an agent to be installed on the windows box. This agent acts as a proxy between the Nagios plugin that does the monitoring and the actual service or attribute of the Windows machine. Without installing an agent on the Windows box, Nagios would be unable to monitor private services or attributes of the Windows box.


Now install the NSClient++ addon on the Wndows machine and using the check_nt plugin nagios will communicate with the NSClient++ addon.
Now follow the below procedure:
Edit the main Nagios config file on the Nagios server:

# vi /usr/local/nagios/etc/nagios.cfg

Remove the leading pound (#) sign from the following line in the main configuration file: 
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg (Remove the # symbol)

Save the file and exit.

Now install the agent NSClient++ on the remote windows box

You can download the agent from http://sourceforge.net/projects/nscplus/


  • Unzip the NSClient++ files into a new C:\NSClient++ directory
  • Open a command prompt and change to the C:\NSClient++ directory
  • Register the NSClient++ system service with the following command:

                     nsclient++ /install
  •  Install the NSClient++ systray with the following command ('SysTray' is case-sensitive):
                     nsclient++ SysTray
  •  Open the services manager and make sure the NSClientpp service is allowed to interact with the desktop (see the 'Log On' tab of the services manager). If it isn't already allowed to interact with the desktop,
check the box to allow it to.

NSClientpp

Edit the NSC.INI file (located in the C:\NSClient++ directory) and make the following changes:
  • Uncomment all the modules listed in the [modules] section, except for CheckWMI.dll and RemoteConfiguration.dll
  • Optionally require a password for clients by changing the 'password' option in the [Settings] section.
  • Uncomment the 'allowed_hosts' option in the [Settings] section. Add the IP address of the Nagios server to this line, or leave it blank to allow all hosts to connect.
  • Make sure the 'port' option in the [NSClient] section is uncommented and set to '12489' (the default port).
Start the NSClient++ service with the following command:

                    nsclient++ /start

If installed properly, a new icon should appear in your system tray. It will be a yellow circle with a black 'M' inside.

Success! The Windows server can now be added to the Nagios monitoring configuration...
Now it is the time for the configuration in the Nagios server

Open the windows.cfg file for editing.

Add a new host definition for the Windows machine that you're going to monitor. If this is the *first* Windows machine you're monitoring, you can simply modify the sample host definition in windows.cfg. Change the host_name,alias, and address fields to appropriate values for the Windows box.
 
define host{
 
                    use                                 windows-server        ; Inherit default values from a Windows server template                                                                                                        (make sure you keep this line!)
                     host_name                winserver (Your server name)
                     alias                              My Windows Server
                     address                       XX.XX.XX.XX (Your server IP)
                     }

Now you can add some service definitions (to the same configuration file) in order to tell Nagios to monitor different aspects of the Windows machine. If this is the first Windows machine you're monitoring, you can simply modify the sample service definitions in windows.cfg.
Add the following service definition to monitor the uptime of the Windows server.
define service{
 
                    use                                                      generic-service
                    host_name                                      winserver (Your windows server name as defined in the                                                                                                                              define host section)
                     service_description                    Uptime
                     check_command                          check_nt!UPTIME
                     }
 
Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.
 
define service{
                     use                                                      generic-service
                     host_name                                      winserver (Your windows server name as defined in the define                                                                                                                host section)
                     service_description                     CPU Load
                     check_command                          check_nt!CPULOAD!-l 5,80,90
                     }
 
 
Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.
 
define service{
                     use                                                      generic-service
                     host_name                                      winserver (Your windows server name as defined in the define                                                                                                                 host section)
                     service_description                     Memory Usage
                     check_command                          check_nt!MEMUSE!-w 80 -c 90
                     }
 
Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.
 
define service{
                     use                                                      generic-service
                     host_name                                      winserver (Your windows server name as defined in the define                                                                                                                host section)
                     service_description                     C:\ Drive Space
                     check_command                          check_nt!USEDDISKSPACE!-l c -w 80 -c 90
                     }

Now save and exit the file.

Verify the sample Nagios configuration files(Syntax verification)

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

# service nagios start

Now check the Nagios GUI to check newly added host and services.



1 comment:

  1. Wow. That is so elegant and logical and clearly explained. Brilliantly goes through what could be a complex process and makes it obvious.

    http://visualpath.in/devops-online-training.html

    ReplyDelete