[Mailman-Users] MM Stats: Showing number of posts
Jon Carnes
jonc at nc.rr.com
Thu Sep 26 15:55:25 CEST 2002
On Thu, 2002-09-26 at 07:23, John Wards wrote:
> Hi,
>
> If there a way of showing the number of posts each user has done on a list?
>
> If this is not in built can someone point me in the right direction of where
> it start?
>
> I don't know any python but I am willing and able to learn. I know PHP could I
> do it using PHP?
>
> Cheers
> John Wards
> Sportnetwork.net
>
===
How about a bash script that sucks the info out of the log files? This
script only pulls the top 10 users, but you can tweak a line and have it
dump all the users.
Note: you should rotate your log files Monthly and keep at least one old
copy. Normally the old copy is named the same as the original file but
has a ".1" added to the end.
Copy the script below into a file and run it the day after you rotate
your log files - point it to run using the ".1" log file.
=== Start of mm_stats file ===
#! /bin/bash
# Run monthly stats on Meeting maker logs
# - top 10 users of each list
# - Number of attempted posts (per list)
# - Total bytes sent (per list)
#
# Mailman's log file to be examined for stats
POST=~mailman/logs/post.1
# create temp file to collect stats
TMPFILE=`mktemp /tmp/mm_stats.XXXXXX` || exit 1
LIST="`/home/mailman/bin/list_lists |awk '{print $1}' |sed -n '2,$p'`"
for i in $LIST
do
echo "Stats from local Mailman list: $i" > $TMPFILE
echo " " >> $TMPFILE
echo -n " Starting: " >> $TMPFILE
head -1 $POST |cut -f1-3 "-d " >> $TMPFILE
echo -n " Ending: " >> $TMPFILE
tail -1 $POST |cut -f1-3 "-d " >> $TMPFILE
echo " ===" >> $TMPFILE
echo -n "Total posts to the list: " >> $TMPFILE
grep -i "post to $i " $POST |wc -l >> $TMPFILE
echo -n "Total SUCCESSFUL posts to the list: " >> $TMPFILE
grep -i "post to $i " $POST |grep success |wc -l >> $TMPFILE
SIZ=`grep -i "post to $i" $POST |grep success |cut -f2 -d= |cut -f1
-d,`
k=0; for j in $SIZ; do k=$(( j + k )); done
echo " Total bytes" = $k >> $TMPFILE
echo " " >> $TMPFILE
echo "Top 10 posters to the list:" >> $TMPFILE
grep -i "post to $i " $POST |cut -f 10 "-d " |sort |uniq -c \
|sort -bgr |head -10 >> $TMPFILE
echo " " >> $TMPFILE
# Mail the collected stats off to the list admin and cc the mailman
user
mail -s "Mailman Stats for List: $i" -c mailman $i-admin <$TMPFILE
done
# remove the temp file
rm $TMPFILE
=== End of mm_stats file ===
Take care - Jon Carnes
More information about the Mailman-Users
mailing list