Page 1 of 1

check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 2:52 pm
by td3201
I'm trying to alert if files ending in .pgp2 exist in this location. However, all I can figure out how to do is alert when files do NOT exist:
/usr/lib/nagios/plugins/check_smb_file -H 10.20.33.129 -f '/narf' -F '.*\.pgp2'

Can anyone think of how to do this?

Thanks!

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 4:42 pm
by abrist
Well, I can think of two ways:
1. Use the negate plugin as it can convert all OKs to CRITICALs.
2. Write a wrapper script to grab the output, check it, and then exit differently if needed.

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 6:29 pm
by Box293
What is the SMB host? A windows box?

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 7:07 pm
by td3201
Box293 wrote:What is the SMB host? A windows box?
Yes, it's all windows.

Thanks for the tip on the negate wrapper. Will look into that.

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 7:14 pm
by Box293
If you install NSClient++ on the windows box it has built in file based checks. For example:

Check the amount of files in a folder (and sub-folders). Generate a warning if more that 500 files exist, critical if more than 1000 files exist.

NSClient++ 0.3.x

Code: Select all

Command:
check_nrpe -H 192.168.142.1 -t 30 -c CheckFiles -a path='C:\\NO BACKUP' pattern=*.* 'filter=size gt 0b' 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000

Output:
{12347 Files Found}, found files: 12347 > critical|'found files'=12347;500;1000
NSClient++ 0.4.1

Code: Select all

Command:
check_nrpe -H 192.168.142.1 -t 30 -c CheckFiles -a path='C:\\NO BACKUP' pattern=*.* 'master-syntax={%total% Files Found}' MaxWarn=500 MaxCrit=1000

Output:
{12347 Files Found}, found files: 12347 > critical|'found files'=12347;500;1000
With these examples you would change pattern=*.* to pattern=*.pgp2

Does this help?

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 9:10 pm
by td3201
Oh, that's a good perspective. I leaned toward check_smb_file because I am checking a windows cluster drive. I can still hit the underlying cluster IP with NSClient++ though. Good tip!

Re: check_smb_file - alerting if files are found

Posted: Tue Feb 17, 2015 9:42 pm
by Box293
There's lots of solutions around which gives us lots of flexibility :)

Let us know how you go with this.