MOnitor the presence of a file in a directory


#1

I wanted to monitor the presence of a file in a directory, How do I do that?


#2

Hi!
what about writing your own script in perl/shell/python to do that ? :wink:

ex:
#!/usr/bin/ksh
FILE=$1
if -f $FILE ]]; then
echo "File $FILE present"
exit 0
fi
echo "File $FILE absent"
exit 2

(I just wrote it, so it may not work as it is, but you’ve got the idea now :))


#3

or you could just use check_file_age and put a really massive age limit on the file, like 3000000000 secs or something (>95 yrs)… this check will show a critical status if the file is missing

[root@localhost libexec]# ./check_file_age -w 3000000000 -c 3000000001 test.txt
FILE_AGE OK: test.txt is 6479845 seconds old and 7467 bytes
[root@localhost libexec]# ./check_file_age -w 3000000000 -c 3000000001 test.txs
FILE_AGE CRITICAL: File not found - test.txs
[root@localhost libexec]#

HTH

/S