From e8b9f0191a557cdf047a09f84cc7e9b4eeed2751 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Wed, 21 Jul 2021 04:56:34 -0500 Subject: [PATCH] Added ability to comment out lines in site list; fixed message being sent even when there are no problems --- http_check_telegram | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/http_check_telegram b/http_check_telegram index e7c79f0..e5c803e 100755 --- a/http_check_telegram +++ b/http_check_telegram @@ -58,7 +58,7 @@ MSG='HTTP/S Problems Found:' FAILURE=false # Check HTTP codes -for site in $(< $CHKLIST); do +for site in $(grep -v "^#\|^$" $CHKLIST); do respcode=$(get_http_code $site) case $respcode in 000) @@ -81,7 +81,9 @@ for site in $(< $CHKLIST); do done || exit 2 # Send compiled message if any problems were found -send_message "$MSG" && printf '%s\n' "Problems found. Message sent via Telegram bot" >&2 || printf '%s\n' "Problems found. Message sending has failed" +if [ "$FAILURE" = "true" ]; then + send_message "$MSG" && printf '%s\n' "Problems found. Message sent via Telegram bot" >&2 || printf '%s\n' "Problems found. Message sending has failed" +fi exit 0