On Fri, 2009-05-15 at 17:13 -0400, Timo Sirainen wrote: > > I could run stats here, with 12.000 users to see what the average size > > is... > > It would be interesting to have some kind of statistics for cur/ > directories and get <cur directory size> divided by <number of files in > cur> and then see how many users have values that are much higher than > average (i.e. how many users have had tons of mails that have since been > deleted).
I wrote an ugly script for it, just change the "find ." path to wherever
your maildirs are and run in some temp directory:
### total.sh
#!/bin/sh
find . -name cur -exec ./diravg.sh {} \; > log
count=`cat log|wc -l`
avg=`cat log | awk '{print $2"+"}'|tr -d '\n'|sed 's/^/(/'|sed "s,+\
$,)/$count\n,"|bc -l`
echo "average: $avg"
echo "3x higher:"
cat log | perl -ne "@l = split(/ /); print if \$l[1] >= ($avg*3);"
### diravg.sh
#!/bin/sh
dir=$1
files=`/bin/ls $dir|wc -l`
if [ $files = 0 ]; then
files=1
fi
ls -ld $dir|head -1|awk "{print \"$dir \" (\$5 / $files);}";
signature.asc
Description: This is a digitally signed message part
