impvored nagios check scripts

This commit is contained in:
Maria Haider 2022-11-21 17:37:25 +01:00
parent 24404af1e3
commit cfeed88b6e
Signed by: mariah
GPG key ID: 7414A760CA747E57
2 changed files with 27 additions and 12 deletions

View file

@ -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

View file

@ -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