Page 1 of 2

check_https: connection refused by host

Posted: Wed Oct 11, 2017 1:36 pm
by nickanderson82
Created config file for the url:
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name xxx.xxx.com
alias xxx.xxx.com
address xxx.xxx.com
}

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
use generic-service ; Name of service template to use
host_name xxx.xxx.com
service_description PING
check_command check_ping!100.0,20%!500.0,60% -4
}

# Define a service to check HTTPS on the local machine.
# Disable notifications for this service by default, as not all users may have HTTPS enabled.

define service{
use generic-service ; Name of service template to use
host_name xxx.xxx.com
service_description HTTPS
check_command check_https
notifications_enabled 0
}

--------------------------
command.cfg edited to
# 'check_https' command definition
define command{
command_name check_https
command_line $USER1$/check_https -H $HOSTADDRESS$ -S -e HTTP $ARG1$
}
-----------------------
check_https plugin

#!/bin/bash
wget='/usr/bin/wget --no-check-certificate --output-document=/tmp/tmp_html -S'
add_uri='https://'
end_uri='/'
PORT=''

if [ $# -gt 1 ]
then
PORT=:$2
fi

if ($wget $add_uri$1$PORT$end_uri$3 2> /tmp/tmp_rep) then
cat /tmp/tmp_rep | grep "HTTP/1"
rm /tmp/tmp_rep
rm /tmp/tmp_html
exit 0
else
cat /tmp/tmp_rep | grep "HTTP/1" || echo 'Connection refused by host'
rm /tmp/tmp_rep
rm /tmp/tmp_html
exit 2
fi;

---------------------------------

What would cause the Connection refused by host? Do I have the wrong command line? I just want the check_https to work. The only thing that worked was ping.

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 1:40 pm
by dwasswa
Hi @nickanderson82,

Check to make sure port 80 on your remote host is open.

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 1:49 pm
by nickanderson82
Internally it is open over port 80, but externally you should be redirected to HTTPS. I'm not sure if that answers your question.

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 2:10 pm
by dwasswa
Change the command definition to:

Code: Select all

# 'check_https' command definition
define command{
command_name check_https
command_line $USER1$/check_https -H $HOSTADDRESS$
}

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 2:30 pm
by nickanderson82
Connection still refused by host. should I pm you the url?

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 4:10 pm
by dwasswa
Yes please that will be very helpful to troubleshoot your issue

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 4:12 pm
by dwasswa
Sorry about that i got it and working on it.

Re: check_https: connection refused by host

Posted: Wed Oct 11, 2017 4:28 pm
by dwasswa
Please remove the

Code: Select all

s 
from check_https so that means your command definition should be:

Code: Select all

# 'check_https' command definition
define command{
command_name check_https
command_line $USER1$/check_http -H $HOSTADDRESS$
}
That should work well. I tested its on my server and it worked.

Let me PM the output from the command when i ran it with your host name.

Also go to your command line and run

Code: Select all

/usr/local/nagios/libexec/check_http -H <your address> 
to test

Aslo run

Code: Select all

/usr/local/nagios/libexec/check_http -H <your address> -S 
-S is if you have ssl enabled.



Let me know what you get.

Re: check_https: connection refused by host

Posted: Thu Oct 12, 2017 9:48 am
by nickanderson82
This is what I am receiving
check_http: Invalid option - SSL is not available

Re: check_https: connection refused by host

Posted: Thu Oct 12, 2017 11:46 am
by dwasswa
Hi @ nickanderson82,

What linux distribution are you using,centos or ubuntu?

It seems you don't have SSL installed and enabled? Do you?

Can you please also post how you defined your service because its supposed to be:

Code: Select all

define service{
use generic-service ; Name of service template to use
host_name xxx.xxx.com
service_description HTTPS
check_command check_http
notifications_enabled 0
}
Some information about configuring SSL on core..https://support.nagios.com/kb/article/n ... l-tls.html