I am trying to monitor a directory for files older than 1 day. That worked fine until I was told that there will usually be a couple of files that are older than a day.

Is it possible to monitor a folder and alert if there are more than 2 files older than 24 hours?

Or, exclude files using wildcards?

Thank you


Article Comments

Dear pdxDavid

I am sorry, both things are not possible with out-of-the-box PRTG sensors. You might want to write a small powershell script for this. You can create a list of files using the powershell commandlet get-childitem and filter it accordingly.


Jul, 2016 - Permalink

I have to check a Linux servcer with a directory of pictures fetched from a webcam. The files have to be maximum 1 hour old.

I made the check with an SSH-check, as described in https://www.paessler.com/manuals/prtg/ssh_script_sensor

The script which prtg executes must be in the directory /var/prtg/scripts of the checked host.

#!/bin/sh
DESCRIPTION="fresh files for webcam rochus"
DIR=/var/www/webcam/wwwroot/rochus
NEWER_THAN_MINUTES=-60

# find out number of fresh files:
NUMBER_OF_FILES_FOUND=`find $DIR -cmin $NEWER_THAN_MINUTES | grep '\.jpg$' |wc -l `

# result for PRTG, see https://www.paessler.com/manuals/prtg/ssh_script_sensor
if [ $NUMBER_OF_FILES_FOUND -gt 0 ]; then
  echo "0:$?:$DESCRIPTION - $NUMBER_OF_FILES_FOUND"
else
  echo "1:$?:$DESCRIPTION - no fresh files found"
fi

Take care about the file-rights:

root@myserver:/var/prtg/scripts# ls -l
-rwxr-xr-x 1 root root 464 Oct 29 16:23 webcam-rochus-fresh-files.sh

# See a good result in a shell
root@brain4:/var/prtg/scripts# ./webcam-rochus-fresh-files.sh
0:0:fresh files for webcam rochus - 12

Oct, 2019 - Permalink