Added configure
This commit is contained in:
parent
0cf4c4025a
commit
09ec695d52
|
@ -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
|
|
@ -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);
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue