NSClient++ Help (#1) - CheckFile syntax (#398) - Message List

CheckFile syntax

Hello,

I'm using CheckFile to count the number of files in a directory but I don't seem to get the results I expect. The Wiki only shows NRPE syntax so I've had to scrape up test commands from the forums. Here's what I've been doing and receiving.

CheckFile file=C:\NSClient\test\*.msg MaxWarn=1 MaxCrit=2
d \NSClient++.cpp(910) Injecting: CheckFile: file=C:\NSClient\test\*.msg, MaxWar
n=1, MaxCrit=2
d \NSClient++.cpp(946) Injected Result: OK 'CheckFile ok'
d \NSClient++.cpp(947) Injected Performance Result: ''no files found'=0;1;2; '
OK:CheckFile ok|'no files found'=0;1;2;

There are 7 .msg files in that directory so I don't think I should be getting an OK. I found a thread here which suggests to run CheckFile2 so here is the output on that.

CheckFile2 file=C:\NSClient\test\*.msg MaxWarn=1 MaxCrit=2
d \NSClient++.cpp(910) Injecting: CheckFile2: file=C:\NSClient\test\*.msg, MaxWa
rn=1, MaxCrit=2
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \CheckDisk.cpp(556) result: 1 -- 0
d \NSClient++.cpp(946) Injected Result: OK 'CheckFile ok'
d \NSClient++.cpp(947) Injected Performance Result: ''no files found'=0;1;2; '
OK:CheckFile ok|'no files found'=0;1;2;

What am I missing?

Tree View Flat View (newer first) Flat View (older first)
  • Message #1224

    humm, off the top of my head... a criteria?

    I am not sure about defaults CheckFile2 works much like CheckEventLog but I would start adding a criteria like filter+size=>0 or some such.

    Again off the top of my head, can see about looking into this is more detail later on.

    mickeM

  • Message #1231

    Great! Your suggestion worked!! Now I have upgraded to 3.6 and it seems that filtering by file type doesn't work.

    CheckFile2 file=C:\NSClient\test\*.msg MaxWarn=1 MaxCrit=2 filter+size=>0
    d NSClient++.cpp(1034) Injecting: CheckFile2: file=C:\NSClient\test\*.msg, MaxWa
    rn=1, MaxCrit=2, filter+size=>0
    d \CheckDisk.cpp(112) Input is: C:\NSClient\test\*.msg / ffffffff
    d \CheckDisk.cpp(126) File pattern: C:\NSClient\test\*.msg\*.*
    d \CheckDisk.cpp(136) File pattern: C:\NSClient\test\*.msg\*.*
    d NSClient++.cpp(1070) Injected Result: OK 'CheckFile ok'
    d NSClient++.cpp(1071) Injected Performance Result: ''no files found'=0;1;2; '
    OK:CheckFile ok|'no files found'=0;1;2;
    

    What's with the added /*.* mask? I can just do a check on the number of all files in a directory but that could be dangerous in some situations. Is this a bug I can get around?

  • Message #1233

    It seems that 0.3.6 has a problem with the file related checks.. I shall investigate tomorrow..

    mickeM

  • Message #1241

    Anyone experiencing this issue....

    I found an open ticket here and Mike's suggestion of using path=c:\mydir and pattern=*.txt worked for me in my test directory.

  • Message #1242

    So after trying out with the above fix on my test directory I seem to have some more issues.

    CheckFile2 path=C:\NSClient\test\ pattern=*.msg filter+size=>0 MaxWarn=300 MaxCr
    it=500
    d NSClient++.cpp(1034) Injecting: CheckFile2: path=C:\NSClient\test\, pattern=*.
    msg, filter+size=>0, MaxWarn=300, MaxCrit=500
    d \CheckDisk.cpp(112) Input is: C:\NSClient\test\ / 10
    d \CheckDisk.cpp(126) File pattern: C:\NSClient\test\\*.msg
    d \CheckDisk.cpp(613) result: 1 -- 1
    ...GOES ON FOR THE NUMBER OF *.msg FILES IN THE DIRECTORY...
    d \CheckDisk.cpp(136) File pattern: C:\NSClient\test\\*.*
    d \NSCHelper.cpp(73) String (9543) to long to fit inside buffer(4096) : 00d68957
    b5
    e NSClient++.cpp(1062) UNKNOWN: Return buffer to small to handle this command.
    BAD_CODE:
    

    There are 252 messages in that directory. Is checkfile unable to handle the number of files I'm looking for here?

  • Message #1252

    The problem is the returned sting which is (usually) limited to something like 1024 chars.

    There might be a truncate=123 option you can add and if not I should add one...

    MickeM

  • Message #1253

    (There is one I just checked)

  • Message #1515

    So I've gotten this running and set up an alias for nrpe checks and it works perfectly. However, there is an aesthetic issue that I would like to know if there is a fix for. The command I'm using sends back a listing of all the files found in a directory but I would MUCH rather it sent back a file count. Is this currently possible?

  • Message #1518

    Next version (next nightly) will have an option called:

    master-syntax which is the "over all" syntax for the command. It takes three options (and char data):

    • %list% A list of all "files" (syntax controls this)
    • %files% number of files
    • %matches% number of files matched

    Like so:

    CheckFile2 MinWarn=10 MinCrit=10 path=D:\WINDOWS\system32 filter+size=gt:0 truncate=10 ignore-errors "master-syntax=%matches%/%files%"
    OK:7177/7...|'found files'=7177;10;10;
    

    (the truncate above sort of destroyed my output but you get the idea I guess)

    Michael Medin

Tree View Flat View (newer first) Flat View (older first)

Subscriptions