update check_curl
This commit is contained in:
parent
c1fb13bad0
commit
2c014863db
|
@ -16,7 +16,8 @@ usage() {
|
|||
-t Timeout in seconds
|
||||
-s Ignore the response status code.
|
||||
-e Expected status code.
|
||||
-S Sanitize HTML when printing to console. Good for Icinga2 Web."
|
||||
-S Sanitize HTML when printing to console. Good for Icinga2 Web.
|
||||
-n Don't return any perfdata if the status code was not 200."
|
||||
exit 3
|
||||
}
|
||||
|
||||
|
@ -33,9 +34,10 @@ TIMEOUT="30"
|
|||
HTTP_METHOD="-X GET"
|
||||
EXPECTED_STATUS_CODE=""
|
||||
SANITIZE_HTML=false
|
||||
DISABLE_PERFDATA=false
|
||||
|
||||
# Parse arguments
|
||||
while getopts "u:w:c:C:LH:M:IpR:st:e:hS" opt; do
|
||||
while getopts "u:w:c:C:LH:M:IpR:st:e:hSn" opt; do
|
||||
case $opt in
|
||||
u)
|
||||
URL="$OPTARG"
|
||||
|
@ -82,6 +84,9 @@ while getopts "u:w:c:C:LH:M:IpR:st:e:hS" opt; do
|
|||
S)
|
||||
SANITIZE_HTML=true
|
||||
;;
|
||||
n)
|
||||
DISABLE_PERFDATA=true
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
|
@ -415,7 +420,7 @@ fi
|
|||
# Check critical string
|
||||
BODY_CONTAINS=" "
|
||||
if [ -n "$CRIT_STRING" ]; then
|
||||
BODY=$(curl -s $FOLLOW_REDIRECTS $INSECURE $HEADERS $RESOLVE $TIMEOUT $URL)
|
||||
BODY=$(curl -s $FOLLOW_REDIRECTS $INSECURE "$HEADERS" "$RESOLVE" "$TIMEOUT" "$URL")
|
||||
# shellcheck disable=SC2076
|
||||
if ! [[ $BODY =~ "$CRIT_STRING" ]]; then
|
||||
if $SANITIZE_HTML; then
|
||||
|
@ -429,5 +434,12 @@ if [ -n "$CRIT_STRING" ]; then
|
|||
fi
|
||||
|
||||
# All checks passed
|
||||
echo "OK - response time was $RESPONSE_TIME seconds, code $HTTP_CODE.${BODY_CONTAINS}-> $URL | $perfdata"
|
||||
|
||||
if $DISABLE_PERFDATA && [ "$HTTP_CODE" != 200 ]; then
|
||||
perfdata_str=""
|
||||
else
|
||||
perfdata_str="| $perfdata"
|
||||
fi
|
||||
|
||||
echo "OK - response time was $RESPONSE_TIME seconds, code $HTTP_CODE.${BODY_CONTAINS}-> $URL $perfdata_str"
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue