Hi,
I need to monitor a directory (F:\ABC) to make sure a sub directory is created each day (F:\ABC\050815, F:\ABC\060815...). I believe it should be possible to do this via Check_Files but I'm not sure exactly how, since I can't find any information which is folder specific.
If anyone can point me in the right direction that would be great.
Using Nagios 4.0.8 and NSClient 0.4.3.
Thanks in advance.
Check Directory for Sub-Directories (Check_Files)
Re: Check Directory for Sub-Directories (Check_Files)
I assume the new directory is created according to a predictable naming scheme? If so you will need some way to tell the Check_Files path parameter which full path to use. You can use the linux command `date +%d%m%y` (note the backticks) to get the date format you appear to be using, and you can stick that in your commands.cfg as the path name.
Former Nagios employee
Re: Check Directory for Sub-Directories (Check_Files)
That plan is a whole lot better than what I was working with (filtering for folders created in the last week and alerting if none of the folders were created in the last day).
Got it to work with the command below, I think that will be sufficient. If you have any suggestions for improvements I'm all ears
Now, because I had to upgrade the client to 0.4.3, check_disk picks up System Volumes and alerts, doh.
Got it to work with the command below, I think that will be sufficient. If you have any suggestions for improvements I'm all ears
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.60 -c check_files -a file="c:\\TEMP" "max-depth=1" "filter=filename='`date +%d%m%y`'" "critical=count<1" empty-syntax=CRITICAL
Re: Check Directory for Sub-Directories (Check_Files)
Spoke too soon. Do you know what the options are for 'empty-state'? I tried 'CRITICAL' and '2' but whatever I put in Nagios returns 'UNKNOWN'. This was apparently a bug in previous versions but should be fixed now.
I'm not sure how to return the 'state' value when manually executing 'check_nrpe'.
Thanks again.
I'm not sure how to return the 'state' value when manually executing 'check_nrpe'.
Thanks again.
Re: Check Directory for Sub-Directories (Check_Files)
The check seems to be working for me. I am running NSClient++ v.0.4.3.143.
I created an empty folder on my workstation (c:\tmp\empty) and tested the check from the CLI:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x
I (0.4.3.143 2015-04-29) seem to be doing fine...
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a file="c:\tmp" "max-depth=1" "filter=filename='empty'" "critical=count<1" empty-state=CRITICAL empty-syntax=CRITICAL
OK: All 1 files are ok|'count'=1;0;1
echo $?
0
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_files -a file="c:\tmp" "max-depth=1" "filter=filename='full'" "critical=count<1" empty-state=CRITICAL empty-syntax=CRITICAL
CRITICAL|'count'=0;0;1
echo $?
2
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check Directory for Sub-Directories (Check_Files)
Cool, that does seem to work, I had CRITICAL as 'CRITICAL' so I guess that's where it was failing.
All good now, thanks both for your help!
Final command I used is:
All good now, thanks both for your help!
Final command I used is:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.60 -c check_files -a file="c:\\TEMP" "max-depth=2" "filter=filename='`date +%d%m%Y`'" "critical=count<1" "empty-state=CRITICAL" "empty-syntax=CRITICAL - Cannot find folder `date +%d%m%Y`"
Re: Check Directory for Sub-Directories (Check_Files)
I am glad we could help!
Be sure to check out our Knowledgebase for helpful articles and solutions!