Page 1 of 1

Nagios plugin to check connectivity

Posted: Wed May 17, 2017 10:05 am
by gaetan321
Hello

I need a plugin that checks external URL connectivity on a specific port

Basically, we monitor a Windows host but that host had issues due to network connectivity to a Network Operation Center. I need to be able to check the connectivity from this host to the NOC

Thanks for your suggestions
Regards
Gaetan

Re: Nagios plugin to check connectivity

Posted: Wed May 17, 2017 10:55 am
by dwhitfield
You can specify the port with the -p flag like so:

Code: Select all

./check_http -H https://something/abc/ -p 8016
Pass just the --help flag to get full help output.

https://assets.nagios.com/downloads/nag ... ios-XI.pdf should be of use in setting this up. Please be mindful of NSClient version #s. We suggest version .4.4.

Re: Nagios plugin to check connectivity

Posted: Fri May 19, 2017 7:12 am
by gaetan321
Thanks for that but check_http is missing in Windows somehow

Re: Nagios plugin to check connectivity

Posted: Fri May 19, 2017 1:33 pm
by tgriep
I just want to verify that you want to monitor a remote windows system's ability to connect to another site, it that correct?
I found this link with a powershell script you would configure in NSCLient++ to monitor a remote site / port.
https://serverfault.com/questions/24046 ... g-nsclient
You would have to put the script on the remote Windows system and create an external check in NSClient++ to use the script.
Take a look at it and if you have any questions, let us know.

Re: Nagios plugin to check connectivity

Posted: Mon May 22, 2017 9:17 am
by gaetan321
Hi Tgriep

This is brilliant. That POSH function is fantastic but I'm not familiar how to integrate it within nsclient to use with check_nt module

I need to check connectivity against 5 websites as defined below.

Test-TCPPort -ComputerName bxenroll.good.com -Port 443
Test-TCPPort -ComputerName gdmdc.good.com -Port 443
Test-TCPPort -ComputerName gdrelay.good.com -Port 443
Test-TCPPort -ComputerName gdentgw.good.com -Port 443
Test-TCPPort -ComputerName gdweb.good.com -Port 44

1) Can I define 1 script to check all of them at the same time or should I define 1 script for each ?
2) What would nsclient.ini look like ?
3) Which command argument would I use if I was to use check_nt ?

Re: Nagios plugin to check connectivity

Posted: Mon May 22, 2017 12:19 pm
by tgriep
1. The best thing is to setup one command and use arguments to pass in the server name you want to test.

2. You would have to setup NSClient to allow NRPE access as the check_nt command cannot run external scripts.
To setup NSClient to run external Scripts, take a look at NSClient's documentation
http://docs.nsclient.org/reference/chec ... alScripts/

An example of the nsclient.ini command would looks like below.

Code: Select all

Test-TCPPort = cmd /c echo scripts\Test-TCPPort -ComputerName $ARG1$ -Port 443; exit $LastExitCode | powershell.exe -command –
To enable NRPE in NSClient++
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

3. The check_nrpe command would look like this. The xxx.xxx.xxx.xxx is the IP address of the server running NSClient. The -c command is what is defined in the nsclient.ini file and the -a "Argument" would be the server you are testing to.

Code: Select all

./check_nrpe -H xxx.xxx.xxx.xxx -c Test-TCPPort -a 'bxenroll.good.com'

Re: Nagios plugin to check connectivity

Posted: Wed May 24, 2017 6:19 am
by gaetan321
I'm getting there but still have an issue

On the server

Code: Select all

# /usr/local/nagios/libexec/check_nrpe -H 172.17.8.143
I (0.4.4.19 2015-12-08) seem to be doing fine...
# /usr/local/nagios/libexec/check_nrpe -H 172.17.8.143 -c Test-TCPPort -a 'bxenroll.good.com'
Unknown command(s): test-tcpport
On the client

Code: Select all

PS C:\Program Files\NSClient++\scripts> .\Test-TCPPort.ps1 bxenroll.good.com -p 443
PS C:\Program Files\NSClient++\scripts> Test-TCPPort bxenroll.good.com -p 443
True
The nsclient.ini looks like this

Code: Select all

allowed hosts = 172.16.8.35,127.0.0.1

[/settings/NRPE/server]
insecure = true
allow arguments = true
allow nasty characters = true
insecure = true
verify mode = none
ssl options = no-sslv2,no-sslv3

[/modules]
CheckExternalScripts = enabled
NRPEServer = enabled

[/settings/external scripts/wrappings]
; POWERSHELL WRAPPING - 
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
Test-TCPPort = cmd /c echo scripts\Test-TCPPort -ComputerName $ARG1$ -Port 443; exit($lastexitcode) | powershell.exe -command -
I'm missing something

Re: Nagios plugin to check connectivity

Posted: Wed May 24, 2017 11:01 am
by tgriep
The command is in the wrong section of the nsclient.ini file.
Edit the file and remove the command from this section

Code: Select all

[/settings/external scripts/wrappings]
and put it under this section. If it doesn't exist, create it.

Code: Select all

[/settings/external scripts/scripts]
test-tcpport = cmd /c echo scripts\Test-TCPPort -ComputerName $ARG1$ -Port 443; exit($lastexitcode) | powershell.exe -command -
Save the file and restart NSClient++ in the Windows server.
Also, the commands definitions may only work when they are lower case and the example above has been changed.