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
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.
Open Server Manager.
Click Configure this local server.
Click the link next to IE Enhanced Security Configuration.
Turn the enhanced security off for both Administrators and Users by selecting the Off option in the pop-up window.
Click OK.
Close Server Manager.
Open a browser and navigate to https://sourceforge.net/projects/nscplus/
Click Download.
Click Run to run the file. If a warning pops up, click Run again.
Once the installer has started, close the browser.
In the installer window, click Next.
Click the checkbox to accept the license agreement and click Next.
Click Complete.
Click Next.
Select the checkboxes for the options Enable common check plugins and Enable NRPE server. The other checkboxes should remain unchecked.
Under Allowed hosts, enter the public IP address for the Nagios server provided on the hands-on lab page.
Click Next.
Click Install. If Windows presents any warnings about the installation, select the option to continue the install.
Run Windows Firewall with Advanced Security.
Click Inbound RuleS in the left window.
Click New Rule… in the right window.
Select the Port option and then click Next.
In the Specific local ports box, enter "5666, 12489" without quotes.
Click Next.
Click Next.
Click Next.
In the Name box, enter "MyPortRules".
Click Finish.
Close Windows Firewall.
Click Finish in the NSC++ installer.
- Run a Manual CPU Check on the Windows Machine
Log in to the lab server using the credentials provided on the hands-on lab page.
ssh cloud_user@PUBLIC_IP_ADDRESS
Install nrpe.
sudo yum install nagios-plugins-nrpe nrpe
Check to see if you can reach the Windows machine.
sudo /usr/lib64/nagios/plugins/check_nrpe -H WINDOWS_IP_ADDRESS
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
Open the
commands.cfg
file.sudo vim /usr/local/nagios/etc/objects/commands.cfg
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$ }
Save your changes and exit the editor.
Create a
windows-server.cfg
file.sudo touch /usr/local/nagios/etc/objects/windows-server.cfg
Edit the
windows-server.cfg
file from the previous step.sudo vim /usr/local/nagios/etc/objects/windows-server.cfg
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 }
Save your changes and exit the editor.
Open the Nagios configuration file.
sudo vim /usr/local/nagios/etc/nagios.cfg
Under the section for Windows machine definitions, enter the following text.
cfg_file=/usr/local/nagios/etc/objects/windows-server.cfg
Save your changes and exit the editor.
Restart the Nagios service.
sudo systemctl restart nagios
- Verify the Service is Running
Open a browser window and navigate to http://PUBLIC_IP_FIRST_SERVER/nagios.
Log in with the username "nagiosadmin" and the password "BlaBla321", without quotes.
Click Services from the left-hand menu.
Click Check CPU usage.
Under Service Commands, click Re-schedule the next check of this service.
In the Check Time box, enter a date and time in the near future.
Click Commit.
Click Services to return to the Service Status Details For All Hosts page.