check_smb_file - alerting if files are found

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.
Locked
td3201
Posts: 15
Joined: Sun Jan 25, 2015 6:16 pm

check_smb_file - alerting if files are found

Post 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!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_smb_file - alerting if files are found

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_smb_file - alerting if files are found

Post by Box293 »

What is the SMB host? A windows box?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
td3201
Posts: 15
Joined: Sun Jan 25, 2015 6:16 pm

Re: check_smb_file - alerting if files are found

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_smb_file - alerting if files are found

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
td3201
Posts: 15
Joined: Sun Jan 25, 2015 6:16 pm

Re: check_smb_file - alerting if files are found

Post 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!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_smb_file - alerting if files are found

Post by Box293 »

There's lots of solutions around which gives us lots of flexibility :)

Let us know how you go with this.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked