How to Monitor and Configure a Windows Server Using Nagios

In this post, i will guide you on how to configure windows machine using and will be monitor via nagios server.

Steps:
1. Download the latest stable version of the NSClient++ addon from http://nsclient.org/nscp/downloads
2. There are two alternate ways to install the NSClient++ on windows server.
a) Double click the file if you downloaded the .msi installer. Set the NSClient to ‘nagiospassword‘.
b) Go to this URL and read the manual properly:

https://hostingcult.com/howto/docs/nagios/monitoring-windows.html
3. Modify the nagios.cfg and add server1.cfg line under windows.cfg line.

[root@server ~]# vi /etc/nagios/nagios.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/etc/nagios/objects/windows.cfg
cfg_file=/etc/nagios/objects/server1.cfg
4. Make a copy the original windows.cfg config file and rename it to server1.cfg, which is the preferred server name.

[root@server ~]# cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/server1.cfg
5. Define windows services that should be monitored.

[root@server ~]# vi /etc/nagios/objects/server1.cfg
# HOST DEFINITIONS

# Define a host for the Windows machine we’ll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
use windows-server ; Inherit default values from a template
host_name server1 ; The name we’re giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.2.2 ; IP address of the host
}

# HOST GROUP DEFINITIONS

# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of this group

define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}

# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}

# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description Uptime
check_command check_nt!UPTIME
}

# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}

# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server1
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
6. Enable Password protection for NSClient. Set the password same as ‘2.a)‘.

# ‘check_nt’ command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s nagiospassword -v $ARG1$ $ARG2$
}
7. Verify the configuration

[root@server ~]# /usr/bin/nagios -v /etc/nagios/nagios.cfg
Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Reading configuration data…
Read main config file okay…
Processing object config file ‘/etc/nagios/objects/commands.cfg’…
Processing object config file ‘/etc/nagios/objects/contacts.cfg’…
Processing object config file ‘/etc/nagios/objects/timeperiods.cfg’…
Processing object config file ‘/etc/nagios/objects/templates.cfg’…
Processing object config file ‘/etc/nagios/objects/localhost.cfg’…
Processing object config file ‘/etc/nagios/objects/server1.cfg’…
Read object config files okay…

Running pre-flight check on configuration data…

Checking services…
Checked 15 services.
Checking hosts…
Checked 2 hosts.
Checking host groups…
Checked 2 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 1 contacts.
Checking contact groups…
Checked 1 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 24 commands.
Checking time periods…
Checked 5 time periods.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors: 0

Things look okay – No serious problems were detected during the pre-flight check
8. Restart the Nagios service.

[root@server ~]# /etc/init.d/nagios restart
Stopping nagios: [ OK ]
Starting nagios: