Monitoring Directory Size

Files keep growing!  Then comes the ultimate crash when they’ve grown too much.  If you would like to monitor the number and size of the files in some directory on your server (and who wouldn’t), Mikayel Vardanyan shows you the easy way in Monitoring Files and Directories with Monitis.Mikayel demonstrates how to use a Python script to create and populate directory-watching monitors.  You do not need to know Python to use them.  You just invoke them from the Unix command line and pass in the required parameters.  It couldn’t be easier.  The scripts are available at GitHub, which means you can copy, personalize, and use them without worrying about copyright issues.It is possible to populate a monitor with a one-line command set up as a cron job.  You first need to create the monitor (also a one-line command) and edit the configuration file (another one-liner).  This trivial effort gives you the file count and the total size of the files in any directory you choose.  Plus you can scan recursively to whatever depth you specify.  Now that’s a productive use of your time!

Setting up and using monitors for multiple directories is just as easy.  Mikayel shows how to monitor two directories.  Extending the concept to more than two is trivial.

Always bear in mind that notifications can be created on a monitor.  In his article, Mikayel sets up an e-mail notification to advise a group of people when the directory size exceeds 85,000 bytes.  He also notes that the notification could just as easily be sent by SMS.

Mikayel’s article is a follow-on to Custom Monitors in Monitis with Python by Hovhannes Avoyan.  This previous article explains that the Python scripts are cross-platform tools, which are especially useful for sysadmins who manage mutliple platforms.  Sure, you can use an OS script to do the same thing, but you will need to create one script for each platform and each script will require more than the three lines required by the Python scripts.

References

Monitoring Files and Directories with Monitis by Mikayel Vardanyan.  Published 2011.07.18 by Monitis at blog.monitis.com/index.php/2011/07/18/monitoring-files-and-directories-with-monitis.  Accessed 2011.12.05.

Custom Monitors in Monitis with Python by Hovhannes Avoyan.  Published 2011.07.07 by Monitis at blog.monitis.com/index.php/2011/07/07/custom-monitors-in-monitis-with-python.  Accessed 2011.12.05.

Try Monitis For Free.  A 15-day free trial.  Your opportunity to see how easy it is to use the Monitis cloud-based monitoring system.  Credit card not required.

The Monitis Exchange at GitHub.  This is the official repository for scripts, plugins, and SDKs that make it a breeze to use the Monitis system to its full potential.

You might also like