From 09ec695d524b4dfd00398ea8d10920edcd1722ed Mon Sep 17 00:00:00 2001 From: hjp Date: Tue, 8 Feb 2000 01:01:06 +0000 Subject: [PATCH] Added configure --- agestat/GNUmakefile | 26 ++++++++++++++++++++++ agestat/agestat.pl | 53 +++++++++++++++++++++++++++++++++++++++++++++ agestat/configure | 30 +++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 agestat/GNUmakefile create mode 100755 agestat/agestat.pl create mode 100644 agestat/configure diff --git a/agestat/GNUmakefile b/agestat/GNUmakefile new file mode 100644 index 0000000..88a59b3 --- /dev/null +++ b/agestat/GNUmakefile @@ -0,0 +1,26 @@ +include GNUmakevars + +BINDIR=/usr/local/dfstat + +all: agestat + +clean: + rm agestat customize + +install: $(BINDIR) $(BINDIR)/agestat + +%: %.pl customize + sh ./customize < $< > $@ + chmod +x $@ + +%: %.sh customize + sh ./customize < $< > $@ + chmod +x $@ + +customize: configure + sh ./configure + +$(BINDIR): + mkdir -p $@ + +include GNUmakerules diff --git a/agestat/agestat.pl b/agestat/agestat.pl new file mode 100755 index 0000000..3c3f64b --- /dev/null +++ b/agestat/agestat.pl @@ -0,0 +1,53 @@ +#!@@@perl@@@ + +use File::stat; +use File::Find; + +$now = time(); +$log_2 = log(2); + +sub wanted { + + $st = lstat($_); + $age = $now - ($st->atime > $st->mtime ? $st->atime : $st->mtime ); + #print $File::Find::name, ": $age sec, ", $st->size, " bytes, ", $st->nlink, " links\n"; + $log2age = log($age >= 1 ? $age : 1) / $log_2; + $hist[$log2age] += $st->size / $st->nlink; +} + +sub logtime2str { + my ($lt) = (@_); + + $t = 1 << $lt; + + if ($t < 60) { + return sprintf ("%5.1f s", $t); + } elsif ($t < 3600) { + return sprintf ("%5.1f m", $t/60); + } elsif ($t < 3600 * 24) { + return sprintf ("%5.1f h", $t/3600); + } elsif ($t < 3600 * 24 * 365.2422) { + return sprintf ("%5.1f d", $t/(3600*24)); + } else { + return sprintf ("%5.1f y", $t/(3600*24*365.2422)); + } +} + + +find(\&wanted, @ARGV); + +print "\n\n"; + +$sum = 0; + +for ($i = 0; $i <= $#hist; $i++) { + $sum += $hist[$i]; +} + +for ($i = 0; $i <= $#hist; $i++) { + $h = $hist[$i]; + $c += $h; + printf("%2d\t%s\t%12.0f\t%5.1f\t%12.0f\t%5.1f\n", $i, logtime2str($i), $h, $h * 100 / $sum, $c, $c * 100 / $sum); +} +print("#-------------------------------------------\n"); +printf("total\t\t%12.0f\t%5.1f\n", $sum, $sum * 100 / $sum); diff --git a/agestat/configure b/agestat/configure new file mode 100644 index 0000000..981a6b2 --- /dev/null +++ b/agestat/configure @@ -0,0 +1,30 @@ +#!/bin/sh +# +echo "#!/bin/sh" > customize.$$ +echo "sed \\" >> customize.$$ +chmod +x customize.$$ + +################################################################ +# find a working perl: +# +for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5 +do + if $i -e 'exit ($] < 5.000)' + then + echo $i works + perl="$i" + break + fi +done +if [ -z "$perl" ] +then + could not find a working perl command, sorry. + exit 1 +fi +echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$ + + +echo >> customize.$$ + +mv customize.$$ customize +