How to add Remote Windows host on Nagios server to monitor

We have already covered in our previous article, Nagios installation on RPM based systems such as CentOS & RHEL and Nagios installation on DEB based systems such as Debian, Ubuntu & Mint, also refer Adding Nagios Remote Linux Host. For Monitoring Windows hosts in Nagios Server, you need to install NSClient++ on your remote Windows systems.

NSClient++ or nscp is powerful and flexible monitoring daemon. It was built for Nagios/Icinga/Neamon. nscp allows nagios to remotely execute on windows machines. This allows you to monitor remote machine metrics (disk usage, CPU load, webserver usage, database server usage, etc…,). NSClient++ Allow remote checks, Monitor system in realtime & Resolve your problems.

Part-1 : Remote Host system configuration.

1) Download and Install NSClient++

Visit NSClient official website and download the package based on your architecture. Then Double click the (.msi) file to initiate the Installation, then hit Run.
windows-host-nagios-server-monitor-1
Wecome screen, then hit Next.
windows-host-nagios-server-monitor-2
Accept License Agreement, then hit Next.
windows-host-nagios-server-monitor-3
Choose installation type “Typical”, then hit Next.
windows-host-nagios-server-monitor-4
To install sample configuration file, then hit Next.
windows-host-nagios-server-monitor-5
Enter the required details (Nagios server IP and password for communication), then hit Next.
windows-host-nagios-server-monitor-6
Hit Install button.
windows-host-nagios-server-monitor-7
Installation under process.
windows-host-nagios-server-monitor-8
Installation completed, then hit Finish.
windows-host-nagios-server-monitor-9
Start >> search “services” >> NSClient++ >> properties >> LogOn “tick” allow service to interact with desktop.
windows-host-nagios-server-monitor-10

Part-2 : Nagois Server configuration.

1) Adding Windows host to Nagios server for monitoring

Create two files inside “/usr/local/nagios/etc/“ to define host and services.

# Navigate to directory #
# cd /usr/local/nagios/etc/

# Create host file, I'm creating linux-hosts.cfg for clarification #
# touch windows-hosts.cfg

# Create service file #
# touch windows-services.cfg

# Add both files to end of the nagios.cfg file with below format #
# nano /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/windows-hosts.cfg
cfg_file=/usr/local/nagios/etc/windows-services.cfg

2) Add/Define new windows host

We don’t know how to define and configure hosts. So, don’t worry because default templates will be available at /usr/local/nagios/etc/objects/ just copy and past it into your host file based on your OS (windows or linux).

# Adding contents to windows-hosts.cfg file from (windows.cfg & templates.cfg) file #
# nano /usr/local/nagios/etc/windows-hosts.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-servers  	; Inherit default values from a template
        host_name       windows.2daygeek.com    ; The name we're giving to this host
        alias           windows.2daygeek.com    ; A longer name associated with the host
        address         192.168.0.155     	; IP address of the host
        }


# Windows host definition template - This is NOT a real host, just a template!

define host{
        name                    windows-servers  ; The name of this host template
        use                     generic-host    ; Inherit default values from the generic-host template
        check_period            24x7            ; By default, Windows servers are monitored round the clock
        check_interval          5               ; Actively check the server every 5 minutes
        retry_interval          1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts      10              ; Check each server 10 times (max)
        check_command           check-host-alive        ; Default command to check if servers are "alive"
        notification_period     24x7            ; Send notification out at any time - day or night
        notification_interval   30              ; Resend notifications every 30 minutes
        notification_options    d,r             ; Only send notifications for specific host states
        contact_groups          admins          ; Notifications get sent to the admins by default
        hostgroups              windows-servers ; Host groups that Windows servers should be a member of
        register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
        }

3) Add/Define service for windows host

We don’t know how to define and configure service for linux hosts. So, don’t worry because default templates will be available at /usr/local/nagios/etc/objects/ just copy and paste it into your service file.

# Adding contents to linux-service.cfg file from (windows.cfg) file #
# nano /usr/local/nagios/etc/windows-service.cfg
# SERVICE DEFINITIONS

# 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               windows.2daygeek.com
        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               2indows.2daygeek.com
        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               windows.2daygeek.com
        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               windows.2daygeek.com
        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               windows.2daygeek.com
        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               windows.2daygeek.com
        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               windows.2daygeek.com
        service_description     Explorer
        check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
        }

4) Add/Define check_nt commands for windows host

We don’t know how to define and configure check_nt commands to communicate with remote server. So, don’t worry because default templates will be available at /usr/local/nagios/etc/objects/ just copy and paste it at the end of your commands.cfg file. Just find “check_nt” and change the password which you gave while installation of NSClient++ on remote windows host.

# Modifying check_nt commands to commands.cfg file from (commands.cfg) file #
# nano /usr/local/nagios/etc/commands.cfg
define command{
command_name	check_nt
command_line	$USER1$/check_nt -H $HOSTADDRESS$ -p india123 -s My2Secure$Password -v $ARG1$ $ARG2$
}

5) Verifying Nagios.cfg file

After making all the above changes, verify the Nagios.cfg file whether it throws any errors.

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

6) Restart Nagios service

Finally restart the Nagios service to take effect.

# service nagios restart                    # [For SysVinit Systems]
# systemctl restart nagios.service          # [For systemd Systems]

7) Access Nagios Web Interface

Navigate your browser to http://localhost/nagios or http://IP-Address/nagios or http://Domain-Name/nagios and enter the Username and Password then click “Hosts”, Here you can see the new windows host which has been added by you.
windows-host-nagios-server-monitor-11
Stay tune with us. Will come with new set of articles.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...