mirror of
https://github.com/byReqz/status.git
synced 2024-11-21 23:33:14 +00:00
make error handling prettier
This commit is contained in:
parent
440ffac50e
commit
a456b0d82e
@ -25,7 +25,12 @@ function get_code {
|
|||||||
elif [[ "$http_code" < 599 && "$http_code" > 499 ]];then
|
elif [[ "$http_code" < 599 && "$http_code" > 499 ]];then
|
||||||
http_code="[\e[31m"$http_code"\e[0m"
|
http_code="[\e[31m"$http_code"\e[0m"
|
||||||
fi
|
fi
|
||||||
|
if [[ -z "$http_code" ]];then
|
||||||
|
http_code="[\e[1;31merror\e[0m]"
|
||||||
|
http_server=""
|
||||||
|
else
|
||||||
http_server=" | \e[1;34m$(echo "$http_raw" | grep -i "server" | sort -u | cut -d " " -f 2 | tr -s '\n' ' '| xargs | sed 's/ / + /g')\e[0m]"
|
http_server=" | \e[1;34m$(echo "$http_raw" | grep -i "server" | sort -u | cut -d " " -f 2 | tr -s '\n' ' '| xargs | sed 's/ / + /g')\e[0m]"
|
||||||
|
fi
|
||||||
http_results=""$http_results"
|
http_results=""$http_results"
|
||||||
$(printf "%-63s%s\n" ["\e[1;35m"$h"\e[0m"] "$http_code""$http_server")"
|
$(printf "%-63s%s\n" ["\e[1;35m"$h"\e[0m"] "$http_code""$http_server")"
|
||||||
}
|
}
|
||||||
@ -39,7 +44,7 @@ function get_ping {
|
|||||||
ping_reach="[\e[32malive\e[0m"
|
ping_reach="[\e[32malive\e[0m"
|
||||||
ping_ms=" | \e[1;34m$(echo "$ping_raw" | cut -d "(" -f 2 | cut -d ")" -f 1)\e[0m]"
|
ping_ms=" | \e[1;34m$(echo "$ping_raw" | cut -d "(" -f 2 | cut -d ")" -f 1)\e[0m]"
|
||||||
else
|
else
|
||||||
ping_reach="[error]"
|
ping_reach="[\e[1;31merror\e[0m]"
|
||||||
ping_ms=""
|
ping_ms=""
|
||||||
fi
|
fi
|
||||||
ping_results=""$ping_results"
|
ping_results=""$ping_results"
|
||||||
|
Loading…
Reference in New Issue
Block a user