柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!
全部博文(1669)
分类: LINUX
2012-03-07 10:40:43
#!/usr/bin/perl -w
# this program will check disk capacity $full and send the warning message
# to $email_address
# (set the threshold to 90 and check it in the daytime so no paging
# is needed)
my $email_address = '';
my $hostname = `/sbin/ifconfig -a|grep inet|head -1|cut -f2 -d":"|cut -f1 -d" "`;
my $dmesg = `dmesg`;
chomp(my $now = `date +"%x %X"`);
my $full = 90; # the threshold to send the warning
my $warn = 95;
my $count = 0;
my ($dev,$total,$used);
my @df_messages = `df|grep -v proc`;
print @df_messages;
shift(@df_messages);
foreach $message (@df_messages) {
chomp($message);
($dev, $total, $used, $available, $capacity, $mount) = split(/\s+/, $message);
$capacity =~ s/(\d+)\%/$1/;
if ($capacity > $full) {
$available[$count] = $available;
$capacity[$count] = $capacity;
$mount[$count] = $mount;
++$count;
$email_address = '' if ($capacity > $warn);
}
}
if ($count > 0) {
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $email_address \n";
print MAIL "Subject: Disk almost full on $hostname ($now)\n";
print MAIL "\n";
for ($i = 0; $i < $count; ++$i) {
print MAIL "There are only $available[$i] KB ($capacity[$i]\% full) left on $mount[$i] \n";
}
}
if ( $dmesg =~ m/ERROR/ )
{
open(EMAIL, "|/usr/sbin/sendmail -t") or die "Can't fork for sendmail: $!\n";
print EMAIL <<_EOF_ ;
To: $email_address
subject: HARDWARE error on $hostname!!!
$hostname needs to be checked right now!
.
_EOF_
close("EMAIL");
} |
-bash-3.00# du -h | sort -n| more
1K ./.dt/appmanager
1K ./.dt/help
1K ./.dt/icons
1K ./.dt/tmp
……….(省略若干行)
914K ./mysql-5.0.37/zlib
933K ./mysql-5.0.37/ndb/src/kernel/blocks/dblqh
938K ./mysql-5.0.37/scripts
945M . //这个东西占太大的空间
957K ./mysql-5.0.37/extra/yassl/taocrypt
959K ./vsftpd-2.0.5
1002K ./mysql-5.0.37/ndb/src/common
-bash-3.00# |
-bash-3.00# ls -al | grep ^-|more
-rw------- 1 root root 810 Apr 29 09:59 .ICEauthority
-rw------- 1 root root 98 Apr 29 09:59 .Xauthority
-rw------- 1 root root 730 Apr 30 07:52 .bash_history
-rwxr-xr-x 1 root root 5111 Apr 29 08:30 .dtprofile
-rw-r--r-- 1 root root 81 Apr 29 08:30 .gtkrc-1.2-gnome2
-rw------- 1 root root 0 Apr 29 08:30 .recently-used
-rw-r--r-- 1 root root 681090961 Feb 28 12:29 10202_database_solx
86.zip
……….(省略若干)
-rw-r--r-- 1 root root 3069440 Apr 29 11:31 tar-1.16-sol10-x86-lo
cal
-rw-r--r-- 1 root root 10895360 Oct 22 2006 tar-1.16.tar
-rw-r--r-- 1 root root 155985 Jul 3 2006 vsftpd-2.0.5.tar.gz
-bash-3.00# |
-bash-3.00# du -h 10202_database_solx86.zip
650M 10202_database_solx86.zip |
本文出自 “sery” 博客,请务必保留此出处http://sery.blog.51cto.com/10037/26141