check_http

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Bryan
Posts: 16
Joined: Wed Apr 13, 2016 11:44 am

check_http

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_http

Post 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.
Former Nagios Employee
Bryan
Posts: 16
Joined: Wed Apr 13, 2016 11:44 am

Re: check_http

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_http

Post by rkennedy »

What happens if you remove the -S?
Former Nagios Employee
Bryan
Posts: 16
Joined: Wed Apr 13, 2016 11:44 am

Re: check_http

Post by Bryan »

It gives socket timed out after 21 seconds.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_http

Post 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
Bryan
Posts: 16
Joined: Wed Apr 13, 2016 11:44 am

Re: check_http

Post by Bryan »

It gives that it cannot make ssl connection.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_http

Post 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.
Former Nagios Employee
Bryan
Posts: 16
Joined: Wed Apr 13, 2016 11:44 am

Re: check_http

Post 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.
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: check_http

Post 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***
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked