Refactor check-webcron.sh to improve error messages

The commit refactors the check-webcron.sh script to improve error messages. Specifically, it changes "URL UNKNOWN" to "WEBCRON UNKNOWN" and adds that prefix to all related error messages.
This commit is contained in:
Jeroen De Meerleer 2023-05-31 17:14:43 +02:00
parent 9db3ebbce6
commit 253e922f99
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -68,14 +68,14 @@ GetOptions() {
break
;;
*)
echo "URL UNKNOWN - ${1} is not a valid parameter"
echo "WEBCRON UNKNOWN - ${1} is not a valid parameter"
exit 3
;;
esac
done
if [ -z ${1+x} ]; then
echo "URL UNKNOWN - url not given"
echo "WEBCRON UNKNOWN - url not given"
exit 3
else
url="${1}/health"
@ -133,5 +133,5 @@ warnfail=$(echo ${jobstotal}\*${warn} | bc -l | awk '{ print int($1+0.5) }')
critfail=$(echo ${jobstotal}\*${crit} | bc -l | awk '{ print int($1+0.5) }')
minfail=0
maxfail=$(echo ${jobstotal})
echo "URL ${rmsg} - ${rdetail:+"$rdetail - "}Response code: ${RESPONSE_CODE} Jobs Total: ${jobstotal} Jobs Due: ${jobsdue} Jobs Running: ${jobsrunning} Jobs Failing: ${jobsfailing}|val=${val}${unitval};$warnval;$critval;$minval;$maxval failing=${jobsfailing}${unitfail};$warnfail;$critfail;$minfail;$maxfail "
echo "WEBCRON ${rmsg} - ${rdetail:+"$rdetail - "}Response code: ${RESPONSE_CODE} Jobs Total: ${jobstotal} Jobs Due: ${jobsdue} Jobs Running: ${jobsrunning} Jobs Failing: ${jobsfailing}|val=${val}${unitval};$warnval;$critval;$minval;$maxval failing=${jobsfailing}${unitfail};$warnfail;$critfail;$minfail;$maxfail "
exit $rval