eid-ops/global/overlay/usr/lib/nagios/plugins/check_eidastest_qa.sh

64 lines
1.2 KiB
Bash
Raw Normal View History

2022-10-04 14:53:09 +02:00
#!/bin/bash
exec_status=$(curl -s https://api.swedenconnect.se/testid/qa/execution-status | jq --raw-output)
exec_status_result=$?
if [[ $exec_status_result -ne 0 ]]; then
echo "CRITICAL - Service FAIL"
exit $STATE_CRITICAL
fi
calculate_time() {
md_date=$(date -d "$1" +%s)
now=$(date +%s)
diff=$(("$md_date"-"$now"))
if ((diff < 0)); then ((diff*=-1)); fi
echo $diff
}
exec_time=$(echo "$exec_status" | jq --raw-output '."last execution result".executiontimestamp')
diff_exec_time=$(calculate_time "$exec_time")
day=$(( 24 * 3600))
if [ "$diff_exec_time" -gt "$day" ]; then
echo "CRITICAL - tests are too old!!"
exit $STATE_CRITICAL
fi
2022-10-04 14:53:09 +02:00
raw_lands=$(curl -s https://api.swedenconnect.se/testid/qa/execution-status | jq --raw-output '."last execution result".failed[].result')
declare -a lands=($(echo $raw_lands | tr "\n" " "))
exit_status=0
output=""
for land in "${lands[@]}"
do
if [[ "$land" == XA* ]]
then
exit_status=1
output="$output $land test country failing"
fi
if [[ "$land" == XB* ]]
then
exit_status=1
output="$output $land test country failing"
fi
done
if [ "$exit_status" -gt 0 ]
then
echo "$output"
2022-10-04 14:53:09 +02:00
else
echo "Tests on test lands are error free"
fi
exit 0