From 0e283f9f628c5ff37d8c83a79b7aa9f31304e37b Mon Sep 17 00:00:00 2001 From: hjp Date: Thu, 27 Jul 1995 14:57:26 +0000 Subject: [PATCH] Initial release --- duwatch/GNUmakefile | 9 +++++++++ duwatch/duwatch | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 duwatch/GNUmakefile create mode 100755 duwatch/duwatch diff --git a/duwatch/GNUmakefile b/duwatch/GNUmakefile new file mode 100644 index 0000000..c1edc9f --- /dev/null +++ b/duwatch/GNUmakefile @@ -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 $< $@ diff --git a/duwatch/duwatch b/duwatch/duwatch new file mode 100755 index 0000000..d621cac --- /dev/null +++ b/duwatch/duwatch @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +$avgfile = "/usr/local/lib/duwatch.avg"; +$root = "/"; +$thresh = 20000; +$period = 30; + +open AVG, $avgfile || die; +while () { + ($size, $name) = split; + $avgdu{$name} = $size; + $all{$name} = 1; +} +close AVG; + +open NEW, "/bin/du -t hfs $root |" || die; +while () { + ($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;