CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Disk usage in Linux


New User

Mar 11, 2007, 12:16 AM

Post #1 of 2 (3342 views)
Disk usage in Linux Can't Post


I have a perl script to send an alert if the disk usge is > 90%.

I want to customize the script to check all the partitions for the user. Can anyone help me.

in attached script I am checking /home only.
Attachments: Copy of (0.77 KB)


Apr 12, 2007, 9:32 AM

Post #2 of 2 (3253 views)
Re: [tsreddy02] Disk usage in Linux [In reply to] Can't Post

The process is much simpler that you may think. You don't need to call the modules. you can do it lik this.

opendir DIR, "/home";
@alldirectories = readdir DIR;

foreach $directory(@alldirectories) {

$diskusage = `du -s $directory`;
$totalusage = ($totalusage + $diskusage);
$diskusage = "";


if ($totalusage > $maxspace){&emailme;}

Just run that from a cron file or incorporate that into a perl server monitring script that runs at some interval.

I figure you can set up the email part. Just be careful of overhead I am not sure how much the summary switch uses. But the summary will allow you to identify the user that is the biggest offendor.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives