HTTP

check_https

Description:

Simply check https host .

Current Version

0.4

Last Release Date

June 22, 2009

Compatible With

Owner


Project Files
Project Notes
It checks if a website runs on https, without checking the certificate. Usage: ./check_https www.example.com Optional: port number ./check_https www.example.com 444 CHANGELOG on v0.4: add timeout
Reviews (6) Add a Review
A Built-in Alternative Solution
by itechnology.zone, December 31, 2021
I did try your script but it was little bit unstable.

Suddenly I have checked the check_http which is already there in the /nagios/libexec/check_http

check_http -S www.sitename.or.ip -w seconds -c seconds

-S Connect via SSL. Port defaults to 443.
-w Response time to result in warning status (seconds)
-c Response time to result in critical status (seconds)

you can add --ssl=1.2 for TLS1.2 (read help)

for example:

/usr/local//nagios/libexec/./check_http -S www.google.com -w 2 -c 5

or

/usr/local//nagios/libexec/./check_http --ssl=1.2 www.google.com -w 2 -c 5

Next

Define The Command Inside commands.cfg

define command {

command_name check_https
command_line $USER1$/check_http -S $ARG1$ -w $ARG2$ -c $ARG3$
}

Define Service

define service {

use local-service ; Name of service template to use
host_name LOCALHOST
service_description HTTPS
check_command check_https!localhost!0.500!0.900
notifications_enabled 1
}

-w -c 0.0 accept millisecond


It's handy when you check multiple internet links either the links is up or down, sites functions, port status.
Helpful? Yes  No 
Edit code
by networkshark, October 31, 2020
I removed ipcalc from the code and replaced it with regex, because ipcalc gave errors of missing parameters.

----- CODE -----
[...]
# Variables definition

# my PID
mypid="$$"
html_tmp="/tmp/tmp_html.$mypid"
rep_tmp="/tmp/tmp_rep.$mypid"
add_uri='https://'
end_uri='/'
PORT=''
exit_code=2
regexIPv4="^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$"
regexIPv6=".*:.*"

[...]
# Give some brain to this script. Detect yourself if we are checking an hostname, an ipv4 or an ipv6

if [[ $1 =~ $regexIPv4 ]]
then
target=ipv4
elif [[ $1 =~ $regexIPv6 ]]; then
target=ipv6
else
# we consider here cases in which the passed argument is DNS name
target=DNS
fi
[...]
----- CODE -----
Helpful? Yes  No 
the script works, please add path support
by marsteel, June 30, 2019
I added $path_uri so the script can check URL like https://www.example.com/WebService/Service.svc

# ./check_https www.example.com 443 WebService/Service.svc


# my PID
mypid="$$"
html_tmp="/tmp/tmp_html.$mypid"
rep_tmp="/tmp/tmp_rep.$mypid"
add_uri='https://'
path_uri=''
end_uri='/'
PORT=''
exit_code=2

if [ $# -lt 1 ]
then
echo "Arguments are missing! Run ./check_https IP_or_DNS port (optional) "
echo "Eg: ./check_https mywebsite.com"
echo "Eg: ./check_https ::ffff:192.168.1.1 444"
exit 1
fi

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

# For https://www.example.com/WebService/Service.svc
# path_uri is WebService/Service.svc

if [ $# -gt 2 ]
then
path_uri=:$3
fi

# Give some brain to this script. Detect yourself if we are checking an hostname, an ipv4 or an ipv6


if ipcalc -sc4 $1
then
target=ipv4
else if ipcalc -sc6 $1
then
target=ipv6
else
# we consider here cases in which the passed argument is DNS name
target=DNS
fi
fi

if [ ! "$target" == "ipv6" ]
then
/usr/bin/wget --timeout=10 --no-check-certificate --output-document=$html_tmp -S $add_uri$1$PORT$end_uri$path_uri 2> $rep_tmp
else
/usr/bin/wget --timeout=10 --no-check-certificate --output-document=$html_tmp -S $add_uri[$1]$PORT$$end_uri$path_uri 2> $rep_tmp

fi
Helpful? Yes  No 
requires ipcalc and >/dev/null 2>&1
by eugene.tsuno, August 31, 2018
Should check ipcalc is installed.

Should redirect ipcal in error to test ip addres:

if ipcalc -sc4 $1 > /dev/null 2>&1
not
if ipcacl -sc1 $1
Helpful? Yes  No 
Works Very Well!
by jkegaly, April 30, 2018
Works very well, just took the check_http command and modified so it would work properly!
Helpful? Yes  No 
Works good with IPv4 addresses
by RogerSik, June 30, 2016
Works good with IPv4 addresses.

With IPv6 addresses i get the error:

Generic error code.
Owner's Reply:

Hi RogerSik,

i submitted a new version with IPv6 support!


1 of 1 found this review helpful.
Helpful? Yes 1 No 0
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.5 (6)
Favorites
1
Views
192,228