What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

File age monitor

Votes:

0

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

age file wildcard

Created on Jul 11, 2016 6:05:38 AM



Best Answer

Accepted Answer

Votes:

1

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

Created on Oct 29, 2019 3:32:05 PM



2 Replies

Votes:

0

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.

Created on Jul 11, 2016 10:52:49 AM by  Arne Seifert [Paessler Support]

Last change on Jul 11, 2016 10:53:42 AM by  Arne Seifert [Paessler Support]



Accepted Answer

Votes:

1

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

Created on Oct 29, 2019 3:32:05 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.