Everything about Web and Network Monitoring

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 Paid Monitor.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 Paid Monitor 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 Paid Monitor by Mikayel Vardanyan.  Published 2011.07.18 by Paid Monitor at blog.monitor.us/index.php/2011/07/18/monitoring-files-and-directories-with-paid-monitor.  Accessed 2011.12.05.

Custom Monitors in Paid Monitor with Python by Hovhannes Avoyan.  Published 2011.07.07 by Paid Monitor at blog.monitor.us/index.php/2011/07/07/custom-monitors-in-paid-monitor-with-python.  Accessed 2011.12.05.

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

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

Post Tagged with

About Warren Gaebel

Warren wrote his first computer program in 1970 (yes, it was Fortran).  He earned his Bachelor of Arts degree from the University of Waterloo and his Bachelor of Computer Science degree at the University of Windsor.  After a few years at IBM, he worked on a Master of Mathematics (Computer Science) degree at the University of Waterloo.  He decided to stay home to take care of his newborn son rather than complete that degree.  That decision cost him his career, but he would gladly make the same decision again. Warren is now retired, but he finds it hard to do nothing, so he writes web performance articles for the Monitor.Us blog.  Life is good!