Initial release

This commit is contained in:
hjp 1995-07-27 14:57:26 +00:00
parent 4bfe108380
commit 0e283f9f62
2 changed files with 46 additions and 0 deletions

9
duwatch/GNUmakefile Normal file
View File

@ -0,0 +1,9 @@
install: $(ROOT)/usr/local/bin/duwatch
install_all:
make install ROOT=/nfs/wsrdb
make install ROOT=/nfs/wifosv
make install ROOT=/nfs/ihssv
make install ROOT=/nfs/wsrcom
$(ROOT)/usr/local/bin/%: %
install $< $@

37
duwatch/duwatch Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/perl
$avgfile = "/usr/local/lib/duwatch.avg";
$root = "/";
$thresh = 20000;
$period = 30;
open AVG, $avgfile || die;
while (<AVG>) {
($size, $name) = split;
$avgdu{$name} = $size;
$all{$name} = 1;
}
close AVG;
open NEW, "/bin/du -t hfs $root |" || die;
while (<NEW>) {
($size, $name) = split;
$size /= 2; # du reports 512 byte blocks :-(
if ($size < $thresh) {next};
$newdu{$name} = $size;
$all{$name} = 1;
}
close NEW;
for $i (keys %all) {
if ($newdu{"$i"} > 2 * ($avgdu{"$i"})) {
printf "%s: %d -> %d\n", $i, $avgdu{$i}, $newdu{$i};
}
$avgdu{$i} = ($avgdu{$i} * ($period - 1) + $newdu{$i}) / $period;
}
open AVG, ">" . $avgfile || die;
for $i (keys %avgdu) {
printf AVG "%d %s\n", $avgdu{$i}, $i;
}
close AVG;