👌 IMPROVE: Monitor check

This commit is contained in:
Austin Ginder 2025-07-23 08:49:09 -04:00
parent 9270035ee5
commit f1896c422e

View file

@ -19,7 +19,7 @@ run_command() {

# Run the health check. Return http_code and body.
response=$(curl --location --max-redirs 7 --user-agent "$user_agent" --write-out "|%{num_redirects}|%{http_code}" --max-time 30 --compressed --silent $url)
response_last_line=$( echo -e "$response" | tail -n1 )
response_last_line=$( printf "%s\n" "$response" | tail -n1 )

# Pull out number of redirects
num_redirects=$( echo -e "$response_last_line" | perl -ne '/.*\|(\d+)\|(\d+)$/&& print $1' )
@ -28,7 +28,7 @@ run_command() {
http_code=$( echo -e "$response_last_line" | perl -ne '/.*\|(\d+)\|(\d+)$/&& print $2' )

# Pull out </html> from bottom if found. Valid code should contain </html> near the bottom.
html_end_tag=$( echo -e "$response" | tail -n12 | perl -wnE'say for /<\/html>/g' )
html_end_tag=$( printf "%s\n" "$response"| tail -n12 | perl -wnE'say for /<\/html>/g' )

# check if </html> found
if [[ $html_end_tag == "</html>" ]]; then