- changed status to on hold
check directory should be able to test the size of the directory
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 (9)
-
reporter -
reporter - edited description
-
reporter - changed status to open
-
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!
-
reporter Issue
#162was marked as a duplicate of this issue. -
+1, this would save a log of scripting effort
-
Any news on this?
-
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
-
+1
I’ve been using a custom
check program
script to monitor this but now I got a use case where I’d like to see graphs of the directory size going back in history. Same graphs as I see when monitoring withcheck filesystem
. Figured this should be a simple thing to setup with monit, but no.If my custom script can do this “fast enough” (using
du -s
command), monit should be able to do it as well. To my knowledge, if the directory is really “really” large or resides on a mounted network disk, the computation can take some time, but it will still be considered fast. - Log in to comment