fixed date formatting; replaced with function

master
Aaron Johnon 4 years ago
parent e8b9f0191a
commit 5ea82e37ef

@ -53,6 +53,10 @@ get_http_code() {
fi fi
} }
print_time() {
date '+%Y-%m-%d %H:%M:%S'
}
# Prepare message header # Prepare message header
MSG='HTTP/S Problems Found:' MSG='HTTP/S Problems Found:'
FAILURE=false FAILURE=false
@ -62,18 +66,18 @@ for site in $(grep -v "^#\|^$" $CHKLIST); do
respcode=$(get_http_code $site) respcode=$(get_http_code $site)
case $respcode in case $respcode in
000) 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" MSG="${MSG}%0A%0A %2B ${site}%0A DNS record not found"
FAILURE=true FAILURE=true
;; ;;
200) 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) 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}" MSG="${MSG}%0A%0A %2B ${site}%0A responding ${respcode}"
FAILURE=true FAILURE=true
;; ;;

Loading…
Cancel
Save