Page 2 of 2

Re: Looking for a file check script

Posted: Wed Apr 01, 2015 8:34 am
by greyclear
Box293 wrote:I hate to distract from the great solutions already provided, however NSClient++ has this functionality built in, no need for extra scripts.

From my website http://sites.box293.com/nagios/guides/c ... es-folders
Make Sure Files Exists That Were Modified In The Last Two Hours
Check a folder to make sure files exist that were modified in the past two hours. Generate a critical alert if no files matching this criteria are found.

NSClient++ 0.3.9 & 0.4.1

Code: Select all

Command:
check_nrpe -H 192.168.142.137 -c CheckFiles -a path='D:\\Important Stuff' pattern=*.* 'filter=written > -2h' 'master-syntax={%total% Files Found}' MinCrit=0

Output when files matching criteria are found:
{1 Files Found}|'found files'=1;0;0

Output when NO files matching criteria are found:
{0 Files Found}, found files: 0 < critical|'found files'=0;0;0
Note: If it is just a specific file you are after, I'm pretty sure you use path= and drop the pattern=

Code: Select all

check_nrpe -H 192.168.142.137 -c CheckFiles -a path='D:\\Important Stuff\\Important File.txt' 'filter=written > -2h' 'master-syntax={%total% Files Found}' MinCrit=0

./check_nrpe -H 10.1.1.207 -c CheckFiles -a path='C:\\Sharepoint Reports\\running\\Reportrun.pdf' 'filter=written > -2h' 'master-syntax={%total% Files Found}' MinCrit=0
Exception processing request: Request command contained illegal metachars!

Re: Looking for a file check script

Posted: Wed Apr 01, 2015 10:46 am
by greyclear
I figured out what the error was. Just added

[/settings/NRPE/server]
allow nasty characters=true

[/settings/external scripts]
allow nasty characters=true

Re: Looking for a file check script

Posted: Wed Apr 01, 2015 11:02 am
by jdalrymple
Is this working for you?

Can we lock this topic and mark solved?

Re: Looking for a file check script

Posted: Wed Apr 01, 2015 12:11 pm
by greyclear
Yep you can thanks!