From 5ea82e37ef51972bb8821b451efd7995468b8fe9 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Wed, 21 Jul 2021 05:01:47 -0500 Subject: [PATCH] fixed date formatting; replaced with function --- http_check_telegram | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/http_check_telegram b/http_check_telegram index e5c803e..b831cac 100755 --- a/http_check_telegram +++ b/http_check_telegram @@ -53,6 +53,10 @@ get_http_code() { fi } +print_time() { + date '+%Y-%m-%d %H:%M:%S' +} + # Prepare message header MSG='HTTP/S Problems Found:' FAILURE=false @@ -62,18 +66,18 @@ for site in $(grep -v "^#\|^$" $CHKLIST); do respcode=$(get_http_code $site) case $respcode in 000) - printf '%s\n' "[$(date '+%Y%m%d %H:%M:%S')]: PROBLEM -- $site: DNS record not found" >&2 + printf '%s\n' "[$(print_time)]: PROBLEM -- $site: DNS record not found" >&2 MSG="${MSG}%0A%0A %2B ${site}%0A DNS record not found" FAILURE=true ;; 200) - printf '%s\n' "[$(date '+%Y%m%d %H:%M:%S')]: OK -- $site returns $respcode" + printf '%s\n' "[$(print_time)]: OK -- $site returns $respcode" ;; 999) - printf '%s\n' "[$(date '+%Y%m%d %H:%M:%S')]: PROBLEM -- $site caused general cURL failure" >&2 + printf '%s\n' "[$(print_time)]: PROBLEM -- $site caused general cURL failure" >&2 ;; *) - printf '%s\n' "[$(date '+%Y%m%d %H:%M:%S')]: PROBLEM -- $site returns $respcode" >&2 + printf '%s\n' "[$(print_time)]: PROBLEM -- $site returns $respcode" >&2 MSG="${MSG}%0A%0A %2B ${site}%0A responding ${respcode}" FAILURE=true ;;