files

check_files

Checks files and directories.

Implementation

WindowsLinuxFreeBSDMacOSX

Examples

Default Check

Alert if there are logs older than 1 hour in /tmp:

check_files path="/tmp" pattern="*.log" "filter=age > 1h" crit="count > 0" empty-state=0 empty-syntax="no old files found" top-syntax="found %(count) too old logs"
OK - All 138 files are ok: (29.22 MiB) |'count'=138;500;600;0 'size'=30642669B;;;0

Check for folder size:

check_files 'path=/tmp' 'warn=total_size > 200MiB' 'crit=total_size > 300MiB'
OK - All 145 files are ok: (34.72 MiB) |'count'=145;;;0 'size'=36406741B;209715200;314572800;0

Example using NRPE and Naemon

Naemon Config

define command{
    command_name         check_nrpe
    command_line         $USER1$/check_nrpe -H $HOSTADDRESS$ -n -c $ARG1$ -a $ARG2$
}

define service {
    host_name            testhost
    service_description  check_files
    use                  generic-service
    check_command        check_nrpe!check_files!'path=/tmp' 'filter=age > 3d' 'warn=count > 500' 'crit=count > 600'
}

Argument Defaults

ArgumentDefault Value
empty-state3 (UNKNOWN)
empty-syntaxNo files found
top-syntax%(status) - %(problem_count)/%(count) files (%(total_size)) %(problem_list)
ok-syntax%(status) - All %(count) files are ok: (%(total_size))
detail-syntax%(name)

Check Specific Arguments

ArgumentDescription
fileAlias for path
max-depthMaximum recursion depth. Default: no limit. ‘0’ disables recursion, ‘1’ includes first sub folder level, etc…
pathPath in which to search for files
pathsA comma separated list of paths
patternPattern of files to search for
timezoneSets the timezone for time metrics (default is local time)

Attributes

Filter Keywords

these can be used in filters and thresholds (along with the default attributes):

AttributeDescription
pathPath to the file
filenameName of the file
nameAlias for filename
fileAlias for filename
fullnameFull name of the file including path
typeType of item (file or dir)
accessLast access time
creationDate when file was created
sizeFile size in bytes
writtenDate when file was last written to
writeAlias for written
ageSeconds since file was last written
versionWindows exe/dll file version (windows only)
line_countNumber of lines in the files (text files)
total_bytesTotal size over all files in bytes
total_sizeTotal size over all files as human readable bytes