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 becaous 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.

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 and make sure it stays below 1 gigabyte:

CheckFileSize ShowAll MaxWarn=1024M MaxCrit=4096M File:WIN=c:\WINDOWS\*.*
WARNING: WIN: 2G (2325339822B)|WIN=2325339822;1073741824;4294967296
define command {
  command_name CheckFileSize
  command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MaxWarn=$ARG1$ MaxCrit=$ARG2$ File:$ARG3$=$ARG4$
}
check_command CheckFileSize!1024M!4096M!WIN!c:\WINDOWS\*.*

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

CheckFileSize ShowAll MinWarn=1G  MinCrit=512M File=c:\pagefile.sys
OK: c:\pagefile.sys: 1G (1610612736B)
define command {
 command_name CheckPageFile
 command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a ShowAll MinWarn=$ARG1$ MinCrit=$ARG2$ File:PageFile=c:\pagefile.sys
}
check_command CheckPageFile!1G!512M

Sample of using individual size for multiple files.:

CheckFileSize MaxWarn=2G MaxCrit=4G File=c:\\pagefile.sys MaxWarn=1K MaxCrit=512 File=c:\\boot.ini
OK all file sizes are within bounds.
define command {
 command_name CheckMyFiles
 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
}
check_command CheckMyFiles

I have had to set this up like this for our Windows Servers

# Check File Size === Greg Small	
define command {
  command_name CheckFileSize
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckFileSize -a MaxWarn=$ARG1$ MaxCrit=$ARG2$ File=$ARG3$
}

define service{
	use				xx-app-service
	host_name			SERVER01
	service_description	        Information store database
	check_command 		        CheckFileSize!13G!15.5G!'d:\\exchsrvr\\mdbdata\\priv1.edb'
	}