check_curl: fix "echo: write error: Broken pipe"

This commit is contained in:
Cyberes 2024-11-28 12:35:15 -07:00
parent 9ffe697ba8
commit 35d75853ec
1 changed files with 11 additions and 11 deletions

View File

@ -16,7 +16,7 @@ usage() {
-t Timeout in seconds
-s Ignore the response status code.
-e Specify the exact response code that should be returned. Cannot be used with -s option.
-S Sanitize HTML when printing to console. Good for Icinga2 Web.
-S Sanitize HTML when printing to console. Good for Icinga2 Web. (not functional)
-n Don't return any perfdata if the status code was not 200.
-a Specify the username and password for authentication in the format username:password"
exit 3
@ -443,10 +443,10 @@ fi
BODY_CONTAINS=""
if [ -n "$CRIT_STRING" ]; then
BODY=$(curl -s $FOLLOW_REDIRECTS $INSECURE $HEADERS $RESOLVE $TIMEOUT $AUTHENTICATION "$URL")
if ! echo "$BODY" | grep -Fq "$CRIT_STRING"; then
if $SANITIZE_HTML; then
BODY=$(echo "$BODY" | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g')
fi
if ! grep -Fq "$CRIT_STRING" <<< "$BODY"; then
# if $SANITIZE_HTML; then
# BODY=$(echo "$BODY" | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g')
# fi
CRIT_STRING_MSG="response body does not contain the required string"
ERROR_MSG="${ERROR_MSG}${CRIT_STRING_MSG}; "
EXIT_CODE=2