Hi Zhengquan,

I send script in perl, that use for this type of disk space monitoring.

vi df.pl

#!/usr/bin/perl
# Available under BSD License. See url for more info:
# 
http://www.cyberciti.biz/tips/howto-write-perl-script-to-monitor-disk-space.html
use strict;
use warnings;
use Filesys::DiskSpace;


# file system to monitor
my $dir = "/home";


# warning level
my $warning_level=10;


# email setup
my $to='[email protected]';
my $from='[email protected]';
my $subject='Low Disk Space';

# get df
my ($fs_type, $fs_desc, $used, $avail, $fused, $favail) = df $dir;


# calculate
my $df_free = (($avail) / ($avail+$used)) * 100.0;


# compare
if ($df_free < $warning_level) {
my $out = sprintf
<http://perldoc.perl.org/functions/sprintf.html>("WARNING Low Disk
Space on $dir : %0.2f%% ()\n",$df_free);


# send email using UNIX/Linux sendmail
open <http://perldoc.perl.org/functions/open.html>(MAIL,
"|/usr/sbin/sendmail -t");


## Mail Header
print <http://perldoc.perl.org/functions/print.html> MAIL "To: $to\\n";
print <http://perldoc.perl.org/functions/print.html> MAIL "From: $from\\n";
print <http://perldoc.perl.org/functions/print.html> MAIL "Subject:
$subject\\n";


## Mail Body
print <http://perldoc.perl.org/functions/print.html> MAIL $out;

close <http://perldoc.perl.org/functions/close.html>(MAIL);
}

You can run this script as a cron job:

@hourly /path/to/df.pl

I expect this help.
Claudio.



On Mon, May 4, 2009 at 11:07 AM, Zhengquan Zhang
<[email protected]>wrote:

> Dear debian community,
>
> I was doing du -ka . | sort -nr once in a while to do disk usage
> analysis.
>
> I was wondering if anybody here are using a package that can do detailed
> disk usage analysis. and the program can email a detailed report to me?
>
> Thanks for any pointers,
>
> --
> Zhengquan
>
>
> --
> To UNSUBSCRIBE, email to [email protected]
> with a subject of "unsubscribe". Trouble? Contact
> [email protected]
>

Reply via email to