In this post, we will install NSClient++ Nagios Core Agent on a Windows host to add it to Nagios Monitoring Server.
Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios - Third Edition. It will be really helpful for you during your Nagios journey.
System Specification:
1) Nagios Monitoring Server – A working Nagios Core Server.
- Hostname - nagios01.example.com
- IP Address - 192.168.229.129/24
2) Windows Host – A windows machine, in which we are going to install NSClient++.
- Hostname - winserver.example.com
- IP Address - 192.168.229.1/24
Install and Configure NSClient++ Nagios Core Agent on Windows:
Download NSClient++ from Nagios Exchange.
We are installing NSClient++ on a 64-bit host, therefore, we have downloaded 64-bit Setup.
Install the downloaded plugin.
Click on Next.
Read and Agree with the License, then click on Next.
Move on with the Typical setup type.
Click on Next.
Append the IP address of Nagios Monitoring Server to Allowed Hosts. Check two options as shown in the screenshot and click on Next. Also note down the Password, because we will need it later.
Click on Install.
NSClient++ has been installed successfully. Click on Finish to complete installation.
Open command prompt and execute following to check status of NSClient++ Agent Service.
C:\Users\Administrator>sc getdisplayname nscp [SC] GetServiceDisplayName SUCCESS Name = NSClient++ (x64) C:\Users\Administrator>sc query nscp SERVICE_NAME: nscp TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 C:\Users\Administrator>netstat -a -n -o | findstr 12489 TCP 0.0.0.0:12489 0.0.0.0:0 LISTENING 6980 TCP 0.0.0.0:12489 0.0.0.0:0 LISTENING 6980 TCP [::]:12489 [::]:0 LISTENING 6980 C:\Users\Administrator>
The NSClient++ service runs on Port 12489/tcp. Our tests show that it is up and listening for the requests.
Now, log on to Nagios Monitoring Server thru ssh and add server-side configurations.
A sample template for windows-servers is already located at /usr/local/nagios/etc/objects/windows.cfg. we added the IP address of my Windows host in it, and keep the remaining services definitions unchanged.
# vi /usr/local/nagios/etc/objects/windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.229.1 ; IP address of the host
}
We also need to add this configuration file to nagios.cfg.
# cat >> /usr/local/nagios/etc/nagios.cfg << EOF > cfg_file=/usr/local/nagios/etc/objects/windows.cfg > EOF
Edit the commands.cfg file in the vi editor and add the Password of NSClient++ in the check_nt command as follows.
# vi /usr/local/nagios/etc/objects/commands.cfg
# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s frAQBc8Wsa1xVPfv -v $ARG1$ $ARG2$
}
Restart Nagios service to reload changes.
# systemctl restart nagios.service
Now open Nagios Web UI in browser.
Checkout the winserver that we have added recently. A couple of services are already defined by the Nagios here.
We have successfully installed NSClient++ Nagios Core Agent on Windows and add that Windows host to Nagios Monitoring Server.
No comments:
Post a Comment