To implement an effective and easy to customizable monitoring of the size of a single file or an entire directory on a Microsoft based system, can be implemented a very simple check.
Making use of the default NetEye monitoring agent for Microsoft, the NSClient++, a new NRPE command can be defined without mayor adaptations in the NSC.ini file.

The only things you have to make sure, are that arguments have been enabled and that the passing of special characters ( in this case we need to pass a ‘\’ ) via NRPE is allowed. The parameters to set are:

  • allow_arguments=1
  • allow_nasty_meta_chars=1

First define a new check command called “check_file_size” of the structure:

Nagios Command definition

$USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxWarn=$ARG1$ MaxCrit=$ARG2$ File:$ARG3$=$ARG4$

Define a Service where you specify the arguments for:

  • ARG1: Warning size
  • ARG2: Critical Size
  • ARG3: File name return description
  • ARG4: The path to the folder or filename.
    C:\\temp\\test.txt
  • C:\\temp\\*

ADVICE: Make sure to escape the used backslashes!

Size Units: B=Bytes K=KiloBytes M=MegaBytes G=GigaBytes

Nagios Service definition example

Nagios Service definition example