2 # vim: set fileencoding=utf-8 ai noet sts=8 sw=8 tw=0:
15 File age checker for nagios. Will alert if the named file is
16 older than the interval (interval default is 60 minutes)
19 -i Interval in minutes at which to alert
26 while getopts f:i:h opt ; do
29 i) INTERVAL="$OPTARG" ;;
34 if [ -z "$FILE" ]; then
35 echo "Need file argument!" >&2
39 if [ ! -r "$FILE" ]; then
40 printf "state file %s is missing or unreadable\n" $FILE
44 if [ "$(( $( date +%s ) - $(stat -c %Y $FILE) ))" -gt "$(( $INTERVAL * 60 ))" ]; then
45 printf "state file %s is older than %d minutes\n" $FILE $INTERVAL
49 printf "state file %s OK: updated on %s\n" $FILE "$(stat -c %y $FILE)"