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://webhostinggeeks.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:                                           [  OK  ]
    

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *