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.

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.

Alex Carter

Alex Carter

Alex Carter is a cybersecurity enthusiast and tech writer with a passion for online privacy, website performance, and digital security. With years of experience in web monitoring and threat prevention, Alex simplifies complex topics to help businesses and developers safeguard their online presence. When not exploring the latest in cybersecurity, Alex enjoys testing new tech tools and sharing insights on best practices for a secure web.