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
Add comment