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