Configure a Check via NSClient++

Hands-On Lab

 

Photo of Ermin Kreponic

Ermin Kreponic

Training Architect

Length

01:30:00

Difficulty

Intermediate

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Configure a Check via NSClient++

Introduction

Your supervisor walked into your office and requested you set up CPU load monitoring on a Windows Server. They had some issues with billing so your company wants to see if the CPU is hitting 80% capacity!

Solution

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.

Conclusion

Congratulations — you've completed this hands-on lab!