check directory should be able to test the size of the directory

Issue #191 open
Tildeslash repo owner created an issue

The check directory statement currently does not provide means to test the size of its directory contents (recursive). The following enhancement is suggested:

check directory with path /path/to/directory
      if size > 100GB then alert

Where size is the combined number of bytes in the directory in files and in sub-directories. Basically what du -hs would report.

The test may also allow to check the directory size vs. the parent filesystem usage, for example:

check directory varlog with path /var/log
    if space usage > 95% [of the filesystem] then exec "/usr/bin/logrotate -f"

Comments (8)

  1. Paddy Newman

    Instead of making changes to the "check directory" feature how about changing the "check filesystem" feature instead?

    For example,

    check filesystem var-log OF DIRECTORY /var/log
        if space usage > 95% then exec "/usr/bin/logrotate -f"

    This would solve my problem which is that not all of my hosts have a /var/log or even a /var filesystem and therefore I can't use one configuration for all hosts.

    It means I'd get all the nice time-series data that you get with the filesystem check. It avoids difficult problems like how to efficiently calculate the size of a large directory containing lots of small files. And it seems like it might be simpler and easier to implement?

    As ever, thanks for the awesome software!

  2. Massimo Sala

    I have the same problem, but from the view of the operating system and system admins, filesystem aren't directories - and viceversa, directories aren't filesystem.

    Moreover, if you ask for the total size of a file-system, usually the file-system drivers keep this metric updated and so they can answer almost immediately.

    If you ask for the size of a directory, this information isn't available, so some routine must traverse all the tree of the directory (and subdirectories) and sum up the size. This routine takes many operations and takes some time ... seconds ... minutes ...

    p.s. I am just a monit user

  3. Log in to comment