Page 1 of 1

Wildcard for Windows path in check_files command

Posted: Mon Jan 14, 2019 6:20 am
by aknotik
Hello,

Does anyone know how to specify a path wildcard for check_files command? I'm trying to create a check command in such manner:
"check_nrpe -a check_files path=c:/foo/*/test/ pattern=*.exe" in such case there is no valid response.
"check_nrpe -a check_files path=c:/foo/foo2/test/ pattern=*.exe" status is OK, files are found.

Thanks in advice!

Re: Wildcard for Windows path in check_files command

Posted: Mon Jan 14, 2019 12:39 pm
by mcapra
What version of NSClient++ is installed on this Windows machine? A lot of NSClient++ command interactions are heavily dependent on the NSClient++ version involved.

The general answer to this question is to leverage the max-depth argument for the CheckDisk/CheckFiles module within NSClient++:
max-depth Maximum depth to recurse
Assuming you had a file tree like this:

Code: Select all

{
  "C:": {
    "foo": [
      "file1.exe",
      "file2.exe"
    ]
    "bar": {
      "baz": [
        "file3.exe"
      ]
    }
  }
}
And a max-depth of 2, file1.exe and file2.exe would match. file3.exe would not match. If you set your max-depth to 3 (or greater), all files would match. +/- 1 maybe, because I don't remember *exactly* how that parameter works and the documentation is vague, but you get the idea? Here's an older post I made on this topic with some sample commands:
https://support.nagios.com/forum/viewto ... 22#p189522

More info:
https://docs.nsclient.org/reference/windows/CheckDisk/

Re: Wildcard for Windows path in check_files command

Posted: Tue Jan 15, 2019 2:14 pm
by cdienger
Thanks for the input @mcapra. Has his response helped resolve the issue @aknotik ?