[Mailman-Users] list statistics - sent to list admins

Jon Carnes jonc at nc.rr.com
Fri Apr 12 22:56:21 CEST 2002


Alright so I modified it right away.  I forgot that originally they wanted to 
mail off the stats to each list admin...

This script lists out certain stats for each list and sends those stats to 
each list admin (and the mailman user).
=== begin script: mm_stats ===
#! /bin/bash
# Run monthly stats on Mailman logs
# Mail stats to each lists admin
#  - Number of attempted posts
#  - Number of Successful posts
#  - Total bytes sent 
#  - top 10 users of each list
#
# Mailman's log file to be examined for stats
POST=~mailman/logs/post

# 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 script: mm_stats ===

The script dumps out the names of all the local Mailman lists and then runs 
through the POST log for each list.  It dumps the stats out to a temp file 
and at the end, emails the contents of the temp file to the list admins (and 
cc's the mailman user).

Unlike some of my other scribblings to the list, this script is tested and 
actually works!  Use it as your own risk, etc...

Again, any suggestions and modifications are welcome.  

Jon Carnes

 --- Original Message: Friday 12 April 2002 03:00 pm ---
> Here is the final list stats script.  If you use this script as is, then
> you should run the script just before rotating your Mailman log files.
>
> If you want to run it right after rotating your log files, and your log
> files rotate by adding a .1 to the end of post (so the rotated file would
> be "post.1") then simply change the line:
>   POST= ...
> and point it to your rotated log file.
>
> Any suggestions or modifications are welcome,
>
> Jon Carnes
>
> ====
>
> #! /bin/bash
> # Run monthly stats on Mailman logs
> #  - top 10 users of each list
> #  - Number of attempted posts (per list)
> #  - Number of Successful posts (per list)
> #  - Total bytes sent (per list)
> #
> POST=~mailman/logs/post
>
> echo "Stats from local Mailman lists:"
>   echo -n "   Starting:  "
>   head -1 $POST |cut -f1-3 "-d "
>   echo -n "   Ending:    "
>   tail -1 $POST |cut -f1-3 "-d "
> LIST="`/home/mailman/bin/list_lists |awk '{print $1}' |sed -n '2,$p'`"
> echo " "
> for i in $LIST
> do
>   echo ====== $i ======
>   echo -n "Total posts to the list: "
>   grep -i "post to $i " $POST |wc -l
>   echo -n "Total SUCCESSFUL posts to the list: "
>   grep -i "post to $i " $POST |grep success |wc -l
>   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
>   echo " "
>   echo "Top 10 posters to the list:"
>   grep -i "post to $i " $POST |cut -f 10 "-d " |sort |uniq -c \
>
>      |sort -bgr |head -10
>
>   echo " "
> done
>
>
> ------------------------------------------------------
> Mailman-Users mailing list
> Mailman-Users at python.org
> http://mail.python.org/mailman/listinfo/mailman-users
> Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py





More information about the Mailman-Users mailing list