CheckFileSize

CheckFileSize is part of the wiki:CheckDisk module

This check does a recursive size calculation of the directory (or file) specified. A request has one or more options described in the table below. The order only matter in that the size has to be specified before the File option this because you can change the size for each drive by specifying multiple Size options.

OptionValuesDescription
MaxWarnsize-valueThe maximum size the directory is allowed before a warning state is returned.
MaxCritsize-valueThe maximum size the directory is allowed before a critical state is returned.
MinWarnsize-valueThe minimum size the directory is allowed before a warning state is returned.
MinCritsize-valueThe minimum size the directory is allowed before a critical state is returned.
ShowAllNoneA Boolean flag to show size of directories that are not in an alarm state. If this is not specified only drives with an alarm state will be listed in the resulting string.
FileFile or directory nameThe name of the file or directory that should have its size calculated. Notice that large directory structures will take a long time to check.
File:<alias>File or directory nameSame as the file option but using a short alias in the returned data.
debugA boolean flag to set debug to true (0.3.8)
ignore-perf-dataA boolean flag to disable returning performance data

The size-value is a normal numeric-value with a unit postfix. The available postfixes are B for Byte, K for Kilobyte, M for Megabyte and finally G for Gigabyte.

Examples

Check the size of the windows directory

Check the size of the windows directory and make sure it stays below 1 gigabyte. Sample Command:

CheckFileSize ShowAll MaxWarn=1024M MaxCrit=4096M File:_WIN=c:\WINDOWS\*.*
WARNING: WIN: 2G (2325339822B)
Nagios Configuration:
define command {
  command_name <<CheckFileSize>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxWarn=$ARG1$ MaxCrit=$ARG2$ File:$ARG3$=$ARG4$
}
<<CheckFileSize>> 1024M!4096M!_WIN!c:\WINDOWS\*.*
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckFileSize -a ShowAll MaxWarn=1024M MaxCrit=4096M File:_WIN=c:\WINDOWS\*.*

Check the size of the pagefile.sys

Check the size of the pagefile.sys and make sure it stays above 1 gigabyte. Sample Command:

CheckFileSize ShowAll MinWarn=1G  MinCrit=512M File=c:\pagefile.sys
OK: c:\pagefile.sys: 1G (1610612736B)
Nagios Configuration:
define command {
  command_name <<CheckFileSize>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MinWarn=$ARG2$  MinCrit=$ARG1$ File=c:\pagefile.sys
}
<<CheckFileSize>> 512M!1G
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckFileSize -a ShowAll MinWarn=1G  MinCrit=512M File=c:\pagefile.sys

Multiple files

Sample of using individual size for multiple files. Sample Command:

CheckFileSize MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
OK: all file sizes are within bounds.
Nagios Configuration:
define command {
  command_name <<CheckFileSize>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
}
<<CheckFileSize>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckFileSize -a MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini

Single file

I have had to set this up like this for our Windows Server. Sample Command:

CheckFileSize MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
OK: all file sizes are within bounds.
Nagios Configuration:
define command {
  command_name <<CheckFileSize>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
}
<<CheckFileSize>> 
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckFileSize -a MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini

Some exchange database thing

Sample Command:

CheckFileSize MaxWarn=13G MaxCrit=15.5G File=d:\\exchsrvr\\mdbdata\\priv1.edb
OK: all file sizes are within bounds.
Nagios Configuration:
define command {
  command_name <<CheckFileSize>>
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=$ARG1$ MaxCrit=$ARG2$ File=$ARG3$
}
<<CheckFileSize>> 13G!15.5G!d:\\exchsrvr\\mdbdata\\priv1.edb
From Commandline (with NRPE):
check_nrpe -H IP -p 5666 -c CheckFileSize -a MaxWarn=13G MaxCrit=15.5G File=d:\\exchsrvr\\mdbdata\\priv1.edb