check_files by extension

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
McHenry
Posts: 16
Joined: Thu Jan 15, 2015 5:01 pm

check_files by extension

Post by McHenry »

Hi,

Using check_files I can specify a pattern to filter the files by extension and this works:

./check_nrpe -H 192.168.1.1 -c check_files -a path="D:\\Testing" pattern="*.txt"

I need to be able to find files that match one of three extensions: txt pdf csv

I have tried specifying multiple file extensions however this does not work.

./check_nrpe -H 192.168.1.1 -c check_files -a path="D:\\Testing" pattern="*.txt" pattern="*.pdf" pattern="*.csv"
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_files by extension

Post by mcapra »

Which version of NSClient++ is your remote Windows machine running? This is somewhat important.

You might consider using a proper filter instead of the pattern directive:
https://docs.nsclient.org/reference/win ... ilter_keys

I haven't tested this at all, but depending on your NSClient++ version it might work:

Code: Select all

./check_nrpe -H 192.168.1.1 -c check_files -a path="D:\\Testing" filter="filename regexp '^.*\.(txt)|(pdf)|(csv)'"
Former Nagios employee
https://www.mcapra.com/
McHenry
Posts: 16
Joined: Thu Jan 15, 2015 5:01 pm

Re: check_files by extension

Post by McHenry »

Slight tweak to get it to work

"filter=filename regexp '/^.*\.(txt|TXT|pdf|PDF|csv|CSV)'"

Could not get the /i to work so had to include both cases

Using newest version of NSClient
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: check_files by extension

Post by cdienger »

Thanks for the update. I'm not sure what type of regex is used by nsclient but I've had similar problems getting $ to work properly.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check_files by extension

Post by npolovenko »

@McHenry, I suggest asking this question on the NSClient forum:
https://forums.nsclient.org/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked