Compare commits

..

2 Commits

Author SHA1 Message Date
540ad83ef8
Improve check-webcron.sh output formatting
The code changes add a printf statement to format the output of the check-webcron.sh script. The new format rounds the value to three decimal places, improving readability.
2023-06-02 13:51:38 +02:00
05220c207a
Improve output formatting for check-url.sh
This commit adds formatting improvements to the output of check-url.sh. Specifically, it formats the response time, DNS lookup time, and connect time to three decimal places. This makes the output more readable and easier to understand.
2023-06-02 13:45:54 +02:00
2 changed files with 5 additions and 3 deletions

View File

@ -91,6 +91,9 @@ url=''
GetOptions "$@" GetOptions "$@"
eval $(curl -L -o /dev/null -s -w 'RESPONSE_CODE=%{response_code}\nRESPONSE_TIME=%{time_total}\nDNS_TIME=%{time_namelookup}\nCONNECT_TIME=%{time_connect}' ${proxy:+"--proxy" "$proxy"} $url) eval $(curl -L -o /dev/null -s -w 'RESPONSE_CODE=%{response_code}\nRESPONSE_TIME=%{time_total}\nDNS_TIME=%{time_namelookup}\nCONNECT_TIME=%{time_connect}' ${proxy:+"--proxy" "$proxy"} $url)
response_time=$(printf %.3f $(echo ${RESPONSE_TIME}))
dns_time=$(printf %.3f $(echo ${DNS_TIME}))
connect_time=$(printf %.3f $(echo ${CONNECT_TIME}))
rdetail="" rdetail=""
if (( $(echo "$RESPONSE_CODE != 200" | bc -l) )); then if (( $(echo "$RESPONSE_CODE != 200" | bc -l) )); then
rval=2 rval=2
@ -107,5 +110,5 @@ else
rmsg="CRITICAL" rmsg="CRITICAL"
fi fi
unit='s' unit='s'
echo "URL ${rmsg} - ${rdetail:+"$rdetail - "}Response code: ${RESPONSE_CODE} Response Time: ${RESPONSE_TIME} DNS Lookup time: ${DNS_TIME} Connect time: ${CONNECT_TIME}|response=${RESPONSE_TIME}${unit} dns-query=${DNS_TIME}${unit} connect=${CONNECT_TIME}${unit}" echo "URL ${rmsg} - ${rdetail:+"$rdetail - "}Response code: ${RESPONSE_CODE} Response Time: ${response_time} DNS Lookup time: ${dns_time} Connect time: ${connect_time}|response=${response_time}${unit} dns-query=${dns_time}${unit} connect=${connect_time}${unit}"
exit $rval exit $rval

View File

@ -102,8 +102,7 @@ jobsdue=$(echo $health | jq '.JobsDue')
jobsrunning=$(echo $health | jq '.JobsRunning') jobsrunning=$(echo $health | jq '.JobsRunning')
jobsfailing=$(echo $health | jq '.JobsFailing') jobsfailing=$(echo $health | jq '.JobsFailing')
val=$(echo "$jobsfailing/$jobstotal" | bc -l) val=$(printf %.3f $(echo "$jobsfailing/$jobstotal" | bc -l))
rdetail="" rdetail=""
if (( $(echo "$RESPONSE_CODE != 200" | bc -l) )); then if (( $(echo "$RESPONSE_CODE != 200" | bc -l) )); then
rval=2 rval=2