Saturday, August 23, 2014

Monitoring Windows Host Status from Nagios server

1:06 PM

To monitor the windows machine from the nagios server we need first install the NSclient++ on windows machine host.

To download the NSclient++ in your windows machine use the below link

Link : http://nsclient.org/nscp/downloads

After downloading finished try to install the package in windows host




















We need change the configuration in NSclient++

Edit following file

C:\Program Files\NSClient++\NSC.ini


Enable following service which need to monitor

;  You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; *                                                               *
; * N O T I C E ! ! ! - Y O U   H A V E   T O   E D I T   T H I S *
; *                                                               *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
NRPEListener.dll
SysTray.dll
CheckEventLog.dll
;CheckHelpers.dll
;CheckWMI.dll
;
; RemoteConfiguration IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS!
;RemoteConfiguration.dll
; NSCA Agent is a new beta module use with care!
;NSCAAgent.dll
; LUA script module used to write your own "check deamon" (sort of) early beta.
;LUAScript.dll
; Script to check external scripts and/or internal aliases, early beta.
;CheckExternalScripts.dll
; Check other hosts through NRPE extreme beta and probably a bit dangerous! :)
;NRPEClient.dll

Enter the Nagios server IP address in allow host line and enable it.

[NSClient]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to

NSClient deamon.
;  If you leave this blank the global version will be used instead.
allowed_hosts= 192.168.1.202
;

Enable port for NSclient++ in windows machine.

;# NSCLIENT PORT NUMBER
;  This is the port the NSClientListener.dll will listen to.
port=12489
;

After changing configuration, start the NSclient service.

path : start --> administrative tools ---> services ---> NSclientpp(nagios)


If your firewall in enable in windows machine then add the nsclient port 12489 in firewall which allow you to access the nagios server.


Switch back to Nagios  Server

Add the check_nt command in the commands.cfg configuration file.

[root@linuxstorages~ ]# vi /etc/nagios/objects/commands.cfg

Add in last line of file

# 'check_nt' command definition
define command{
        command_name    check_nt
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
        }
:wq (save)


Edit the nagios configuration file nagios.cfg to enable the window configuration.

[root@linuxstorages~ ]# vi /etc/nagios/nagios.cfg

Line no 39 enable windows.cfg file

# Definitions for monitoring a Windows machine
cfg_file=/etc/nagios/objects/windows.cfg

:wq (save)

Add the window remote host configuration in windows.cfg file and you can add multiple windows host machine in this file, no need create separate file for each windows host machine.

[root@linuxstorages~ ]#vi /etc/nagios/objects/windows.cfg


define host{
        use             windows-server  ; Inherit default values from a template
        host_name       winserver-2     ; The name we're giving to this host
        alias           My Windows Server       ; A longer name associated with the host
        address         192.168.1.200     ; IP address of the hos

        }

define service{
        use                     generic-service
        host_name               winserver-2
        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               winserver-2
        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               winserver-2
        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               winserver-2
        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               winserver-2
        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               winserver-2
        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               winserver-2
        service_description     Explorer
        check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
        }


After adding the windows host information restart the Nagios server.

[root@linuxstorages~ ]# /etc/init.d/nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

Check the Window host machine status in admin URL








Written by

2 comments :

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism