Checkfilesize wildcard in filepath

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
brianp89
Posts: 18
Joined: Thu May 08, 2014 10:53 am

Checkfilesize wildcard in filepath

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

Re: Checkfilesize wildcard in filepath

Post by abrist »

Can you post a link to this plugin? Or if it is short/custom, post here in code wraps?
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: Checkfilesize wildcard in filepath

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
brianp89
Posts: 18
Joined: Thu May 08, 2014 10:53 am

Re: Checkfilesize wildcard in filepath

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Checkfilesize wildcard in filepath

Post 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.
Former Nagios employee
brianp89
Posts: 18
Joined: Thu May 08, 2014 10:53 am

Re: Checkfilesize wildcard in filepath

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Checkfilesize wildcard in filepath

Post by tmcdonald »

Nice to hear! We'll go ahead and close this up now.
Former Nagios employee
Locked