Skip to content

folder

Use case

Watch a directory (or a single file) for count/size/age drift, or specific files being present with the right permissions/ownership - e.g. “an export job dropped at least 3 files in the last 5 minutes”, or “this backup file isn’t older than 24h”.

Configuration

Field Type Meaning
path string required - a file or a directory
recursive bool scan subdirectories too; default false
no_store bool don’t keep per-file detail (skip file_list and the has_files/permission/uid/gid targets, for large directories); default false
send_content bool single-file path only: add a file_content item with the first ~100 bytes; default false
send_list bool add a folder_file_list item listing every scanned file; default false
filter_extension string space-separated suffixes (e.g. .conf .pdf) - only matching files count
filter_regexp string only files whose name matches (anchored at the start, not the end) count

target: sub-block, all optional, evaluated in this fixed order - the first one that fails wins (critical) and stops evaluation:

Field Type Meaning
files_min / files_max int total file count bounds
size_max / size_min int total size bounds (bytes)
age_max int (sec) every file must be newer than this
age_min int (sec) every file must be older than this
has_recent int (sec) at least one file newer than this
has_old int (sec) at least one file older than this
has_files []string every named file must be present (skipped if no_store)
permission string every file’s mode must equal exactly (skipped if no_store)
uid / gid int every file’s owner must equal exactly (skipped if no_store)

Output

Item Type Meaning
folder_path string the configured path (tag)
folder_name string the check name (tag)
folder_files int (files) files counted (datapoint)
folder_dirs int (dirs) directories seen (datapoint)
folder_size int (bytes) total size of counted files (datapoint)
folder_youngest int (sec) age of the newest file (datapoint, only if at least one file counted)
folder_oldest int (sec) age of the oldest file (datapoint, only if at least one file counted)
folder_file_list string one line per file (send_list only)
file_content string first ~100 bytes (send_content, single file only)

Example

checks:
  - module: folder
    name: mydata
    conf:
      path: /data/demo
      recursive: true
      target:
        files_min: 3
        age_max: 300