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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



tsreddy02
New User

Mar 11, 2007, 12:16 AM

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

Hi,

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 Disk_Usage_alert.pl (0.77 KB)


hacker01
Novice

Apr 12, 2007, 9:32 AM

Post #2 of 2 (2990 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.

http://bumblebeeware.com/monitor/

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