diff --git a/global/overlay/usr/lib/nagios/plugins/check_eidastest_prod.sh b/global/overlay/usr/lib/nagios/plugins/check_eidastest_prod.sh index 989b29cb..45cbeb3e 100755 --- a/global/overlay/usr/lib/nagios/plugins/check_eidastest_prod.sh +++ b/global/overlay/usr/lib/nagios/plugins/check_eidastest_prod.sh @@ -2,16 +2,17 @@ . /usr/lib/nagios/plugins/utils.sh +check_return() { + if [[ $1 -ne 0 ]]; then + echo "CRITICAL - Service FAIL" + exit $STATE_CRITICAL + fi +} exec_status=$(curl -s https://api.swedenconnect.se/testid/prod/execution-status | jq --raw-output .) exec_status_result=$? - - -if [[ $exec_status_result -ne 0 ]]; then - echo "CRITICAL - Service FAIL" - exit $STATE_CRITICAL -fi +check_return "$exec_status_result" calculate_time() { md_date=$(date -d "$1" +%s) @@ -24,6 +25,9 @@ calculate_time() { exec_time=$(echo "$exec_status" | jq --raw-output '."last execution result".executiontimestamp') +exec_time_result=$? +check_return "$exec_time_result" + diff_exec_time=$(calculate_time "$exec_time") day=$(( 24 * 3600)) @@ -36,6 +40,9 @@ fi raw_lands=$(echo "$exec_status" | jq --raw-output '."last execution result".failed[].result') +raw_lands_result=$? +check_return "$raw_lands_result" + declare -a lands=($(echo "$raw_lands" | tr "\n" " ")) exit_status_warning=0 diff --git a/global/overlay/usr/lib/nagios/plugins/check_eidastest_qa.sh b/global/overlay/usr/lib/nagios/plugins/check_eidastest_qa.sh index 6e75dba9..a4c02bd3 100755 --- a/global/overlay/usr/lib/nagios/plugins/check_eidastest_qa.sh +++ b/global/overlay/usr/lib/nagios/plugins/check_eidastest_qa.sh @@ -2,15 +2,17 @@ . /usr/lib/nagios/plugins/utils.sh +check_return() { + if [[ $1 -ne 0 ]]; then + echo "CRITICAL - Service FAIL" + exit $STATE_CRITICAL + fi +} + 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 +check_return "$exec_status_result" calculate_time() { md_date=$(date -d "$1" +%s) @@ -23,6 +25,9 @@ calculate_time() { exec_time=$(echo "$exec_status" | jq --raw-output '."last execution result".executiontimestamp') +exec_time_result=$? +check_return "$exec_time_result" + diff_exec_time=$(calculate_time "$exec_time") day=$(( 24 * 3600)) @@ -36,6 +41,9 @@ fi raw_lands=$(curl -s https://api.swedenconnect.se/testid/qa/execution-status | jq --raw-output '."last execution result".failed[].result') +raw_lands_result=$? +check_return "$raw_lands_result" + declare -a lands=($(echo $raw_lands | tr "\n" " ")) exit_status=0