We have a use case as in when a directory has a file more than an hour old, it should be treated as CRITICAL and alert. If there is no file present or if the file is present but is written less than an hour, its OK and no alerting is needed.
I have referenced to https://support.nagios.com/kb/article.p ... file_count and set my check, but not getting desired output:
As you can see there are two issues:
1. It does a recursive search of folders which I dont want.
2. Even though I have a file dated 2017, it still says OK.
You do not have the required permissions to view the files attached to this post.
I expected the output to say 2 files found which are older than 1 hour and not adding the two directories as well.
Considering I put a fresh file just before running the query, so that means the file is written less than an hour. But the remaining two files are older and should be reported as Critical.
You do not have the required permissions to view the files attached to this post.
Looking this over, one option would be to use a pattern to search on the filenames (so the directories are not counted). Do these files have a coming name syntax (eg. test*.txt)?