Looking for a file check script

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
greyclear
Posts: 27
Joined: Tue Sep 09, 2014 7:50 am

Re: Looking for a file check script

Post 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!
greyclear
Posts: 27
Joined: Tue Sep 09, 2014 7:50 am

Re: Looking for a file check script

Post 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
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Looking for a file check script

Post by jdalrymple »

Is this working for you?

Can we lock this topic and mark solved?
greyclear
Posts: 27
Joined: Tue Sep 09, 2014 7:50 am

Re: Looking for a file check script

Post by greyclear »

Yep you can thanks!
Locked