Page 1 of 1

check_files by extension

Posted: Mon Mar 12, 2018 7:35 am
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"

Re: check_files by extension

Posted: Mon Mar 12, 2018 8:51 am
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)'"

Re: check_files by extension

Posted: Mon Mar 12, 2018 4:10 pm
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

Re: check_files by extension

Posted: Tue Mar 13, 2018 3:54 pm
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.

Re: check_files by extension

Posted: Tue Mar 13, 2018 4:08 pm
by npolovenko
@McHenry, I suggest asking this question on the NSClient forum:
https://forums.nsclient.org/