From b291fd1a3fdea3567dd6075438cc2859f443f557 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 22 Jun 2023 13:11:38 -0600 Subject: [PATCH] check_curl: show when using substring --- check_curl.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check_curl.sh b/check_curl.sh index 35d41b7..ea688a7 100755 --- a/check_curl.sh +++ b/check_curl.sh @@ -395,15 +395,18 @@ elif [ $(echo "$RESPONSE_TIME_MS > $WARN_TIME" | bc) -eq 1 ]; then fi # Check critical string +BODY_CONTAINS=" " if [ -n "$CRIT_STRING" ]; then BODY=$(curl -s $FOLLOW_REDIRECTS $INSECURE $HEADERS $RESOLVE $TIMEOUT $URL) if ! [[ $BODY =~ "$CRIT_STRING" ]]; then # if ! echo "$BODY" | grep -q "$CRIT_STRING"; then echo "CRITICAL - response body does not contain '$CRIT_STRING': $BODY" exit 2 + else + BODY_CONTAINS=" and contained substring " fi fi # All checks passed -echo "OK - response time was $RESPONSE_TIME seconds -> $URL | response_time=${RESPONSE_TIME_MS}ms;$WARN_TIME;$CRIT_TIME;0;;" +echo "OK - response time was $RESPONSE_TIME seconds${BODY_CONTAINS}-> $URL | response_time=${RESPONSE_TIME_MS}ms;$WARN_TIME;$CRIT_TIME;0;;" exit 0