check_https: connection refused by host

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_https: connection refused by host

Postby nickanderson82 » Wed Oct 11, 2017 1:36 pm

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.
nickanderson82
 
Posts: 29
Joined: Wed Sep 27, 2017 11:27 am

Re: check_https: connection refused by host

Postby dwasswa » Wed Oct 11, 2017 1:40 pm

Hi @nickanderson82,

Check to make sure port 80 on your remote host is open.
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Re: check_https: connection refused by host

Postby nickanderson82 » Wed Oct 11, 2017 1:49 pm

Internally it is open over port 80, but externally you should be redirected to HTTPS. I'm not sure if that answers your question.
nickanderson82
 
Posts: 29
Joined: Wed Sep 27, 2017 11:27 am

Re: check_https: connection refused by host

Postby dwasswa » Wed Oct 11, 2017 2:10 pm

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$
}
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Re: check_https: connection refused by host

Postby nickanderson82 » Wed Oct 11, 2017 2:30 pm

Connection still refused by host. should I pm you the url?
nickanderson82
 
Posts: 29
Joined: Wed Sep 27, 2017 11:27 am

Re: check_https: connection refused by host

Postby dwasswa » Wed Oct 11, 2017 4:10 pm

Yes please that will be very helpful to troubleshoot your issue
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Re: check_https: connection refused by host

Postby dwasswa » Wed Oct 11, 2017 4:12 pm

Sorry about that i got it and working on it.
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Re: check_https: connection refused by host

Postby dwasswa » Wed Oct 11, 2017 4:28 pm

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.
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Re: check_https: connection refused by host

Postby nickanderson82 » Thu Oct 12, 2017 9:48 am

This is what I am receiving
check_http: Invalid option - SSL is not available
nickanderson82
 
Posts: 29
Joined: Wed Sep 27, 2017 11:27 am

Re: check_https: connection refused by host

Postby dwasswa » Thu Oct 12, 2017 11:46 am

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/nagios-core-configuring-ssl-tls.html
User avatar
dwasswa
 
Posts: 222
Joined: Tue Jul 25, 2017 3:32 pm

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 32 guests