-if [ "$(( $( date +%s ) - $(stat $FOLLOW -c %Y $FILE) ))" -gt "$(( $INTERVAL * 60 ))" ]; then
- printf "state file %s is older than %d minutes\n" $FILE $INTERVAL
- exit 2
-fi
+while [ "$#" -gt 0 ]; do
+ f="$1"; shift
+ total=$((total + 1))
+
+ if [ ! -e "$f" ]; then
+ msg="${msg}state file $f is missing or unreadable\n"
+ EXIT=2
+ failed="$f $failed"
+ elif [ -n "$ZEROFAIL" ] && ! [ -s "$f" ]; then
+ msg="${msg}state file $f is empty\n"
+ EXIT=2
+ failed="$f $failed"
+ elif [ "$(( $( date +%s ) - $(stat $FOLLOW -c %Y "$f") ))" -gt "$(( $INTERVAL * 60 ))" ]; then
+ msg="${msg}state file $f is older than $INTERVAL minutes (updated on $(stat $FOLLOW -c %y "$f"))\n"
+ EXIT=2
+ failed="$f $failed"
+ else
+ msg="${msg}state file $f OK: updated on $(stat $FOLLOW -c %y "$f")\n"
+ ok="$f $ok"
+ fi
+done