Here we are going to see how to monitor windows machines using Nagios tools. Please follow the below steps to add the windows hosts in nagios.
Nagios server
Operating System: Centos release 6.4
Hostname: sever.local
IP Address: 192.168.1.5
Windows Machine
Operating System: Windows 7
Hostname: winserver
IP Address: 192.168.1.22
Step 1: Install Prerequisites Package on Windows machine
NSClinet++ Agent is act as proxy agent between windows and nagios.
== Download the latest stable version of the NSClient++ addon from http://files.nsclient.org/legacy/NSClient%2B%2B-0.3.9-x64.zip
== Unzip the NSClient++ files into a new C:\NSClient++ directory
== Open a command prompt and execute the below commads to install the NSClient++ agent
C:\>cd "NSClient++"
C:\NSClient++>
C:\NSClient++>nsclient++ /install
C:\NSClient++>nsclient++ SysTray
C:\NSClient++>services.msc
== Now right click on NSClient go to Properties and in ‘Log On‘ tab and click the check box “Allow service to interact with the desktop“ and click “Apply” and “Ok”.
Step 2: NSClient++ configuration
Edit the NSC.INI file (located in the C:\NSClient++ directory) and make the following changes:
1. In [modules] section, uncomment all the modules, except for CheckWMI.dll and RemoteConfiguration.dll
2. In [Settings] section, uncomment the ‘allowed_hosts’ option and add the IP address of the Nagios server address
3. In [NSClient] seciton, make sure the ‘port’ option is uncommented and set to ‘12489’
4. Optionally require a password for clients by changing the ‘password’ option in the [Settings] section
To start the NSClient++ service run the following command.
C:\NSClient++>nsclient++ /start
If you made above changes properly, a new icon should appear in your system tray. It will be a yellow circle with a black ‘M’ inside.
Step 3: Configuring Nagios host and service
Uncomment the Windows Configuration in nagios configuration file
[root@server.local ~]# vi /usr/local/nagios/etc/nagios.cfg
Search for windows string and uncommment the below line
# Definitions for monitoring a Windows machine
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
[root@server.local ~]# vi /usr/local/nagios/etc/objects/windows.cfg
Make the changes accoring to your setup
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias Windows Server ; A longer name associated with the host
address 192.168.1.22 ; IP address of the Windows host
}
In service definition, make changes according to your need, here i have kept remaining setting as it is.
Save and exit (:wq!)
Step 4: Define the command for check_nt
If you specified a password in the NSClient++ configuration file on the Windows machine, then you need to modify the check_nt command definition.
[root@server.local ~]# vi /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$ $ARG2$
}
Save and exit (:wq!)
Step 5: Restart the nagios daemon
[root@server.local ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If everything is ok then restart the nagios service
[root@server.local ~]# /etc/init.d/nagios restart
Now open your web browser and type http://ipaddress-of-nagios-server/nagios and provide nagiosadmin credentials. Check our newly added windows machine is listed or not.
That’s it.