#!/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