check_files by extension

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_files by extension

Postby McHenry » Mon Mar 12, 2018 7:35 am

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

Re: check_files by extension

Postby mcapra » Mon Mar 12, 2018 8:51 am

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/windows/CheckDisk/#check_files_filter_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
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3462
Joined: Thu May 05, 2016 3:54 pm

Re: check_files by extension

Postby McHenry » Mon Mar 12, 2018 4:10 pm

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

Re: check_files by extension

Postby cdienger » Tue Mar 13, 2018 3:54 pm

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.
User avatar
cdienger
Support Tech
 
Posts: 2191
Joined: Tue Feb 07, 2017 11:26 am

Re: check_files by extension

Postby npolovenko » Tue Mar 13, 2018 4:08 pm

@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.
User avatar
npolovenko
Support Tech
 
Posts: 2492
Joined: Mon May 15, 2017 5:00 pm


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 20 guests