Configure a Check via NSClient++

1.5 hours
  • 4 Learning Objectives

About this Hands-on Lab

Here we will need to configure NSClient++ to work with Nagios so that we can monitor resource consumption on a windows machine. You might have noticed that most of the work thus far has has been done on Linux.
Nagios is a versatile tool that can monitor pretty much anything with a network card, so let us not exclude windows machines of which there usually are a lot in an office environment.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install NSClient++ on the Windows Server
  1. You first need to log in via RDP to the windows server and download the NSClient++. Use the IP address from the hands-on lab page and connect through port 3389.

  2. Open Server Manager.

  3. Click Configure this local server.

  4. Click the link next to IE Enhanced Security Configuration.

  5. Turn the enhanced security off for both Administrators and Users by selecting the Off option in the pop-up window.

  6. Click OK.

  7. Close Server Manager.

  8. Open a browser and navigate to https://sourceforge.net/projects/nscplus/

  9. Click Download.

  1. Click Run to run the file. If a warning pops up, click Run again.

  2. Once the installer has started, close the browser.

  3. In the installer window, click Next.

  4. Click the checkbox to accept the license agreement and click Next.

  5. Click Complete.

  6. Click Next.

  7. Select the checkboxes for the options Enable common check plugins and Enable NRPE server. The other checkboxes should remain unchecked.

  8. Under Allowed hosts, enter the public IP address for the Nagios server provided on the hands-on lab page.

  9. Click Next.

  10. Click Install. If Windows presents any warnings about the installation, select the option to continue the install.

  11. Run Windows Firewall with Advanced Security.

  12. Click Inbound RuleS in the left window.

  13. Click New Rule… in the right window.

  14. Select the Port option and then click Next.

  15. In the Specific local ports box, enter "5666, 12489" without quotes.

  16. Click Next.

  17. Click Next.

  18. Click Next.

  19. In the Name box, enter "MyPortRules".

  20. Click Finish.

  21. Close Windows Firewall.

  22. Click Finish in the NSC++ installer.

Run a Manual CPU Check on the Windows Machine
  1. Log in to the lab server using the credentials provided on the hands-on lab page.

    ssh cloud_user@PUBLIC_IP_ADDRESS
  2. Install nrpe.

    sudo yum install nagios-plugins-nrpe nrpe
  3. Check to see if you can reach the Windows machine.

    sudo /usr/lib64/nagios/plugins/check_nrpe -H WINDOWS_IP_ADDRESS
  4. Check the CPU load of the Windows machine.

    sudo /usr/lib64/nagios/plugins/check_nrpe -H WINDOWS_IP_ADDRESS -c alias_cpu
Configure the Nagios Server
  1. Open the commands.cfg file.

    sudo vim /usr/local/nagios/etc/objects/commands.cfg
  2. Add the following text to the file.

    
    define command {
    
        command_name        check_cpu
        command_line        /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    
    }
  3. Save your changes and exit the editor.

  4. Create a windows-server.cfg file.

    sudo touch /usr/local/nagios/etc/objects/windows-server.cfg
  5. Edit the windows-server.cfg file from the previous step.

    sudo vim /usr/local/nagios/etc/objects/windows-server.cfg
  6. Add the following lines to the file. Remember to replace WINDOWS_IP_ADDRESS with the IP address provided in the hands-on lab page.

    define host {
    
        use             windows-server
        host_name       windowsSrv
        alias           winSrv
        address         WINDOWS_IP_ADDRESS
    }
    
    define hostgroup {
    
        hostgroup_name  windows-servers
        alias           win-srvs
        members         windowsSrv
    }
    
    define service {
    
        use                     generic-service
        host_name               windowsSrv
        service_description     check CPU usage
        check_command           check_cpu!alias_cpu
    }
  7. Save your changes and exit the editor.

  8. Open the Nagios configuration file.

    sudo vim /usr/local/nagios/etc/nagios.cfg
  9. Under the section for Windows machine definitions, enter the following text.

    cfg_file=/usr/local/nagios/etc/objects/windows-server.cfg
  1. Save your changes and exit the editor.

  2. Restart the Nagios service.

    sudo systemctl restart nagios
Verify the Service is Running
  1. Open a browser window and navigate to http://PUBLIC_IP_FIRST_SERVER/nagios.

  2. Log in with the username "nagiosadmin" and the password "BlaBla321", without quotes.

  3. Click Services from the left-hand menu.

  4. Click Check CPU usage.

  5. Under Service Commands, click Re-schedule the next check of this service.

  6. In the Check Time box, enter a date and time in the near future.

  7. Click Commit.

  8. Click Services to return to the Service Status Details For All Hosts page.

Additional Resources

You first need to log in via RDP to the windows server and download the NSClient++. Then start the installation and go through the installation wizard. After a successful installation, log in to the Nagios server via SSH and define the following objects:

  • Host object
  • Host group object
  • Service object
  • Command object

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?