check_file_ages_in_dirs

check_file_ages_in_dirs

Usage:

check_file_ages_in_dirs --dirs | -d  [-w ] [-c ] [-W ] [-C ] [-t ] [-s] [-V] [--check-dirs] [--base-dir ]

Usage:

check_file_ages_in_dirs --help | -h

Description:

This plugin pulls all files in each specified directory, and checks their created time against the current time.  If the maximum age of any file is exceeded, a warning/critical message is returned as appropriate.

This is useful for examining backup directories for freshness. Tested to work on Linux/FreeBSD/OS X.

The following arguments are accepted:

  --dirs | -d  A space separated list of directories to examine.  Each

                  directory will be checked for the age of all files in the

                  directory.

  -w            (Optional) Generate a warning message if any created file is

                  older than this value.  Defaults to 26 hours.

  -c             (Optional) Generate a critical message if any created file is

                  older than this value.  Defaults to 52 hours.

  -W           (Optional) If set, a warning message will be returned if the

                  specified directory doesn't exist, or there are less than the

                  number of specified files in the specified directory.

  -C            (Optional) If set, a critical message will be returned if the

                  specified directory doesn't exist,or there are less than the

                  number of specified files in the specified directory.

  -t              (Optional) The time unit used for the -w and -c values.  Must

                  be one of: seconds, minutes, hours, days.  Defaults to hours.

  -s             (Optional) Print a summary of OK, Warning and Critical files

                  Cannot be used together with -V (Verbose)

  -V            (Optional) Output verbose information about all checked

                  files.  Default is only to print verbose information for

                  files with non-OK states.

                  Cannot be used together with -s (summary)

  --check-dirs   (Optional) If set, directories inside the specified directory

                        will also be checked for their creation time. Note that this

                        check is not recursive.  Without this option, only real files

                        inside the specified directory will be checked.

  --base-dir      (Optional) If set, this path will be prepended to all

                       checked directories.

  --help | -h      Print this help and exit.

Examples:

Generate a warning if any file in /backups is more than 26 hours old,

and a critical if it's more than 52 hours old...

check_file_ages_in_dirs -d "/backups"

Generate a warning if any file in /var/foo or /var/bar is more than one week

old, a critical if it's more than two weeks old, or a critical if there are

less than 3 files in either directory.

check_file_ages_in_dirs -d "/var/foo /var/bar" -w 7 -c 14 -t days -C 3

Caveats:

Although multiple directories can be specified, only one set of warning/critical times can be supplied.

Linux doesn't seem to have an easy way to check file/directory creation time, so file/directory last modification time is used instead.