Page 1 of 1

check_http

Posted: Thu Jun 30, 2016 10:54 am
by Bryan
Hi All

We are using Nagios Core 4.0.8
And we are using Check_by method instead of NRPE.

We are trying to monitor json in our web server.
when we run below command it gives specific output.


curl https://api.dev.google.com/versions.json --proxy proxyserver.com:8080 -o /dev/null;echo $?
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1107 100 1107 0 0 3097 0 --:--:-- --:--:-- --:--:-- 3395
0


And when we try to run From nagios it gives error. Like socket timed out and Name or service not known
HTTP CRITICAL - Unable to open TCP socket.

And command.cfg

# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}

define command{
command_name check_http_content_hh
command_line $USER1$/check_http -H $HOSTADDRESS$ -w 5 -c 10 --ssl -u $ARG1$ -s $ARG2$
}
# 'check_http_content_proxy' command definition
define command{
command_name check_http_content_proxy
command_line $USER1$/check_http -I $ARG1$ -P $ARG2$ -H $HOSTADDRESS$ -w 5 -c 10 --ssl -u $ARG3$ -s $ARG4$
}



and have defined service as

define service{
use generic-service
host_name above-property-stg
service_description https
check_command check_http! -H api.dev.google.com -u /versions.json -S -w 10 -c 20
}

This command gives socket timed out after 10 seconds error.

define service{
use generic-service
host_name above-property-stg
service_description https
check_command check_http_content_proxy! -I proxyserver.com -p 8080 -H api.dev.google.com -u /versions.json -S -w 10 -c 20
}

And this command gives Name or service not known
HTTP CRITICAL - Unable to open TCP socket.


So how can i monitor if there is any issue with command line, please let me know.

Thank you Everyone.

Re: check_http

Posted: Thu Jun 30, 2016 10:58 am
by rkennedy
Your service definition contains parameters that are already being passed the the command -

Code: Select all

define service{
use generic-service
host_name above-property-stg
service_description https
check_command check_http_content_proxy! -I proxyserver.com -p 8080 -H api.dev.google.com -u /versions.json -S -w 10 -c 20
Your check_command is not using ! to differentiate the $ARG$ values, so all of this is still going to classify as $ARG1$.

Looking at the command_line, it's -

Code: Select all

command_name check_http_content_proxy
command_line $USER1$/check_http -I $ARG1$ -P $ARG2$ -H $HOSTADDRESS$ -w 5 -c 10 --ssl -u $ARG3$ -s $ARG4$
You'll need to adjust this accordingly, one suggestion would be -

Code: Select all

command_name check_http_content_proxy
command_line $USER1$/check_http $ARG1$
which would let you pass everything in the check_command as you're doing now.

Re: check_http

Posted: Thu Jun 30, 2016 11:20 am
by Bryan
I tried and made changes
changed command line to


defined service as

define command{
command_name check_http_content_proxy1
command_line $USER1$/check_http $ARG1$
}

define service{
use generic-service
host_name above-property-stg
service_description https
check_command check_http_content_proxy1! -I proxyserver.com -p 8080 -H api.dev.google.com -u /versions.json -S -w 10 -c 20
}


But now it gives error CRITICAL - Cannot make SSL connection.

Re: check_http

Posted: Thu Jun 30, 2016 11:22 am
by rkennedy
What happens if you remove the -S?

Re: check_http

Posted: Thu Jun 30, 2016 11:26 am
by Bryan
It gives socket timed out after 21 seconds.

Re: check_http

Posted: Thu Jun 30, 2016 11:50 am
by ssax
Please SSH into your Nagios server and test from the command line (using this exact command):

Code: Select all

/usr/local/nagios/libexec/check_http -I proxyserver.com -p 8080 -u https://api.dev.google.com/versions.json -S -H api.dev.google.com -vvv
Pleaseend us the entire output.

Thank you

Re: check_http

Posted: Thu Jun 30, 2016 12:21 pm
by Bryan
It gives that it cannot make ssl connection.

Re: check_http

Posted: Thu Jun 30, 2016 1:16 pm
by rkennedy
Bryan wrote:It gives that it cannot make ssl connection.
Please post the entire output, as @ssax mentioned. The -vvv will provide us with verbosity on what's going on with your headers, so we can actually have something to work with.

Re: check_http

Posted: Thu Jun 30, 2016 1:35 pm
by Bryan
bash-4.1$ /usr/local/nagios/libexec/check_http -I proxyserver.com -p 8080 -u https://api.dev.google.com/versions.json -S -H api.dev.google.com -vvv
CRITICAL - Cannot make SSL connection.


This is what output was @rkennedy and @ssax. It just showed me that much details.

Re: check_http

Posted: Thu Jun 30, 2016 1:59 pm
by bwallace
Perhaps others will have different troubleshooting steps to suggest, but I'm curious what a tcpdump conducted on the Proxy server, while reproducing, will show us.
If you have access to the proxy server's CLI run this command, then reproduce the issue:

tcpdump -s 0 -i any host <Nagios XI server IP address> -w capture.pcap

(Ctl+C to stop capture)

Post the capture file here, but if it contains sensitive data PM it to me.

***get a capture of the successful curl example, this way we can compare working vs non-working --- if you can do this quickly within the same tcpdump, great. If not then two pcaps will suffice: 1 curl, 1 Nagios check. Please title them accordingly***