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.
DESCRIPTION="fresh files for webcam rochus"
# 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"
echo "1:$?:$DESCRIPTION - no fresh files found"
Take care about the file-rights:
[email protected]:/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
[email protected]:/var/prtg/scripts# ./webcam-rochus-fresh-files.sh
0:0:fresh files for webcam rochus - 12