From 1beafaef78d5a39998bb87db87f4b3beb22c4474 Mon Sep 17 00:00:00 2001 From: Maria Haider Date: Tue, 2 Jun 2020 15:57:09 +0200 Subject: [PATCH] new nagios check --- .../plugins/check_eidas_metadata.age.sh | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 global/overlay/usr/lib/nagios/plugins/check_eidas_metadata.age.sh diff --git a/global/overlay/usr/lib/nagios/plugins/check_eidas_metadata.age.sh b/global/overlay/usr/lib/nagios/plugins/check_eidas_metadata.age.sh new file mode 100644 index 00000000..5a538e39 --- /dev/null +++ b/global/overlay/usr/lib/nagios/plugins/check_eidas_metadata.age.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +. /usr/lib/nagios/plugins/utils.sh + +abs() { + [[ $[ $@ ] -lt 0 ]] && echo "$[ ($@) * -1 ]" || echo "$[ $@ ]" +} + +diff_warn=$2 +diff_crit=$3 + +tmpx=$(mktemp) + +function finish { + rm -f $tmpx +} +trap finish EXIT + +cat>$tmpx< + + + + + + +EOF + +dstr=$(wget -qO- $1 | xsltproc $tmpx -) +if [ $? -ne 0 ]; then + echo "CRITICAL - Service $1 FAIL" + echo $status + exit $STATE_CRITICAL +fi + +exp=$(date -d $dstr +%s) +now=$(date +%s) + +d=$(expr $exp - $now) +if [ $d -ge $diff_crit ]; then + echo "CRITICAL - metadata in $1 expires in $d seconds" + echo $status + exit $STATE_CRITICAL +elif [ $d -ge $diff_warn ]; then + echo "WARNING - metadata in $1 expires in $d seconds" + echo $status + exit $STATE_WARNING +else + echo "OK - metadata in $1 expires in $d seconds" + echo $status + exit $STATE_OK +fi