Hi all -
I’ve been trying to figure out how to implement check_file –
What I need to do is check to ensure that there are greater than X number of files in a folder, dated less than 48 hours.
This is for ensuring that a backup job has run, and created all the files necessary.
I see lots of samples for checking for too many files - people looking for log directories not getting rotated,etc.
But I’m trying to do the reverse – ensure that there ARE files in a directory-
Any clues or am I just being obtuse and not seeing the syntax right in front of me?
thanks…
This is a small script I use for a similar task. Call with the path, warning # and critical # of files in the directory.
#! /bin/bash
FILEPATH=$1
WARN=$2
CRIT=$3
# mtime -2 is anything modified in the last two days
COUNT=$(find $FILEPATH -mtime -2 -type f 2> /dev/null | wc -l )
# Critical
if "$COUNT" -le $CRIT ]
then
echo "CRITICAL: Less than $CRIT found: $COUNT"
exit 3
fi
# Warning
if "$COUNT" -le $WARN ]
then
echo "WARNING: Less than $WARN found: $COUNT"
exit 2
fi
thanks timb
I guess now would be a good time to mention that I need to do this on Windows?
Once I’m back from vacation, if no one has responded with a windows version of that, I might see if there’s some way to rewrite that…
thanks tim