Page 1 of 1

Checkfilesize wildcard in filepath

Posted: Wed Dec 03, 2014 4:08 pm
by brianp89
Hello Nagios forums,

I am trying to implement a pretty simple check to see if a file exists with the name "test-***" where *** will be any random numbers and/or letters. I have tried several combos in Nagios including:

checkfilesize -a D:/downloads/test1/test-% --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-%%% --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-$% --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-$%%% --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-$* --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-$*** --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-* --nodatamode -c _ItemCount=1:
checkfilesize -a D:/downloads/test1/test-*** --nodatamode -c _ItemCount=1:

but none will match the file named "test-123". Obviously if I hardcode the numbers into the check, it works as intended, but these numbers will constantly be changing. Does anyone know how I can use a wildcard in the filepath for this check?

Thank you

Re: Checkfilesize wildcard in filepath

Posted: Wed Dec 03, 2014 6:06 pm
by abrist
Can you post a link to this plugin? Or if it is short/custom, post here in code wraps?

Re: Checkfilesize wildcard in filepath

Posted: Wed Dec 03, 2014 10:43 pm
by Box293
If you are using NSClient++ you can use the build in module CheckDisk/CheckFiles which can do exactly that.

Here is an example.
The following file exists: "C:\Downloads\test1\test-123.txt" AND it has some text added to it (so it doesn't have a byte size of 0).
These commands find any files that start with test-

Using NSClient++ 0.3.9:

Code: Select all

Command:
./check_nrpe -H win2008r2-01 -t 30 -c CheckFiles -a path='C:\\Downloads\\test1' pattern='test-*' 'filter=size gt 0b' max-dir-depth=0 MinCrit=0

Output:
test-123.txt|'found files'=1;0;0
Using NSClient++ 0.4.1.105:

Code: Select all

Command:
./check_nrpe -H win2008r2-01 -t 30 -c CheckFiles -a path='C:\\Downloads\\test1' pattern='test-*' max-dir-depth=0 MinCrit=0

Output:
test-123.txt|'found files'=1;0;0

Re: Checkfilesize wildcard in filepath

Posted: Thu Dec 04, 2014 9:08 am
by brianp89
The plugin I am using is check_wmi_plus.pl:

http://edcint.co.nz/checkwmiplus/?q=faq ... mmandlines

And here's a readme:

http://mastermonsvr.smartmon.com.au/mp- ... mi_plus.pl

I also submitted a query to the check_wmi_plus developers asking about this issue in case they've got a solution. Thanks in advance for the responses

Re: Checkfilesize wildcard in filepath

Posted: Thu Dec 04, 2014 5:54 pm
by tmcdonald
I don't see "wildcards" anywhere in the "checkfilesize" section for that readme, but I do see it for other checks. My guess is it is not implemented.

Re: Checkfilesize wildcard in filepath

Posted: Fri Dec 05, 2014 9:54 am
by brianp89
I received a reply from the checkwmiplus developer:
It can be done but it can timeout the plugin so I did not include it.
Try this

add -d -z to the command line (without any wildcards) Look near the top of the output for the wmic command used "QUERY:"
Run the wmic command from the command line to make sure it works

Modify the wmic query using "like" and "%"
eg
name like "c:\\temp\\PC_task_manager%"'

Try that, see if it works for you
I figured out a different check to use that works, but I've posted this response here for anyone else who may be interested. Feel free to mark this as solved.

Thanks for the help

Re: Checkfilesize wildcard in filepath

Posted: Fri Dec 05, 2014 10:18 am
by tmcdonald
Nice to hear! We'll go ahead and close this up now.