Hi
How can I only print the file systems that are more than 95% full.
I used the df -k output and tried to check for each file system and then print only the ones that meet the criteria... But my solution seems cloodgie ...
Hey, put your scripts up so that we can see if there is any better solution.
df -k |awk '($2-$3)/$2*100 > 95 {print $0}'
You can print $1(file-system) or $7(mounted directory) instead of $0
Good Luck
I had to search, but I had written this Perl script for automatic notification if the filesystem was greater than some arbirtary percentage:
#!/usr/bin/perl
# auswipe, 5 Apr 2002
# Tested under OpenBSD 2.9
# auswipe sez : "No guarantees!"
$upperLimit = 80; # Upper Limit in % for a File System
$mailTarget = "joe\@blow.com"; # Target for the automatic e-mail message
open(STATS, "df -h\|grep '%'|") || die "$!";
my @fileStats = <STATS>;
foreach $entryLine (@fileStats) {
chomp($entryLine);
$entryLine =~ s/\s+/ /g;
my @fsStats = split(/ /, $entryLine);
$fsStats[4] =~ s/%//g;
if ($fsStats[4] >= $upperLimit) {
open(MAIL, "|mail -s \"FileSystem $fsStats[0] Getting Full!\" $mailTarget ") || die "Can't open m
ail!";
select(MAIL);
print << "EOF";
The FileSystem $fsStats[0] is getting full.
Currently, the file system is ${fsStats[4]}% full. The upper
limit has been placed at ${upperLimit}%.
Please attend to this matter.
-auswipe
This message has been created automatically. Please do not respond to this message.
EOF
close(MAIL);
};
};
close(STATS);