Posts or Comments 08 February 2010
buy pcanywhere buy windows 7 ultimate price autocad electrical 2010 download buy windows 7 license download corel painter for mac buy microsoft office for mac online cheapest microsoft office for mac windows xp best buy download autodesk lustre cheap adobe photoshop elements 8 buy windows 7 professional cheap best buy quicken 2010 adobe pagemaker cost buy windows vista ultimate autocad inventor price adobe audition 3 price buy cs4 photoshop cheap photoshop elements download buy 3ds max 2010 photoshop lightroom mac inventor lt 2010 download buy adobe indesign for mac adobe fireworks price buy windows 2008 enterprise dreamweaver mac oem buy visual studio 2005 pro adobe flash cs4 professional download adobe contribute review buy adobe illustrator cs2 buy adobe flash cs4 for mac buy dreamweaver cs3 for mac buy adobe premiere pro 2.0 buy steinberg nuendo 4 cheap illustrator software buy inventor 2009 buy windows 7 professional oem cs3 master collection trial cheapest windows xp home edition download adobe flash cs4 professional mac windows 7 ultimate best price windows xp sp3 download buy microsoft project professional 2007 buy ms visual studio 2008 quicken 2008 download buy cubase sx illustrator download after effects price get windows 7 ultimate 32bit turbotax 2009 deals buy quickbooks pro 2010 cheapest windows 7 ultimate full version adobe creative suite 4 for mac windows vista best price microsoft office 2003 cheapest microsoft word 2003 product key buy windows 7 pro oem buy adobe photoshop cs4 extended vista 64 sp2 windows datacenter price microsoft windows 7 ultimate cheap buy outlook 2007 only microsoft office project professional 2007 download cheapest windows 7 pro visio 2007 download buy office enterprise 2007 buy dreamweaver cs3 windows 7 discount adobe robohelp download download adobe framemaker 9 buy contribute cs3 buy adobe contribute cs3 buy windows 2008 server buy adobe cs4 web premium buy norton 360 download microsoft windows 7 home premium best price adobe dreamweaver for mac download buy ms office 2003 buy microsoft money 2007 buy production premium cs4 windows 7 professional oem vs retail adobe contribute cs4 download cheap windows xp professional microsoft streets and trips 2009 download cheap windows vista business buy adobe cs3 for mac buy windows 7 ultimate 64 bit oem buy corel draw 11 buy acrobat professional buy windows xp home buy autocad architecture 2009 microsoft frontpage license windows 7 home premium discount buy word 2003 buy visual studio 2003 microsoft encarta premium 2009 download corel draw 11 for mac buy windows 7 home premium oem should i buy windows 7 now buy microsoft windows 7 professional download microsoft mappoint dreamweaver cs4 oem where to buy windows xp license buy quickbooks enterprise buy microsoft office canada buy indesign cs4 adobe dreamweaver cs4 discount adobe premiere full download purchase quickbooks buy quickbooks premier 2010 photoshop elements download price of windows 7 home premium buy windows 2003 datacenter ms excel 2003 download buy premiere cs4 buy microsoft project 2003 windows vista home basic iso buy autocad electrical cheap where can i buy powerpoint 2003 microsoft mappoint europe 2006 download after effects for mac price autocad 2009 price download lightroom 2.5 cs4 production premium mac purchase windows vista home basic download adobe premiere elements 8 buy windows vista business 32 bit excel 2007 price buy norton 360 cheap buy microsoft visual studio 2005 photoshop elements 8 where to buy quickbooks enterprise discount cheap quicken 2010 master collection cs4 student buy word 2003 download soundbooth cs4 download download streets and trips 2007 buy frontpage 2003 buy autodesk 3ds max cheap adobe illustrator cs4 price adobe premiere elements 8 buy visio 2007 pricing buy autocad mechanical 2009 buy turbotax deluxe buy windows 7 oem 64 bit buy streets and trips 2009 buy after effects cs4 adobe flash mac download buy microsoft outlook 2007 product key adobe cs3 design premium download buy onenote 2003 windows vista premium download buy cs3 cheap microsoft office 2010 price buy microsoft office online framemaker cost adobe premiere download windows 7 ultimate 64 bit download microsoft digital image suite 9 adobe cs4 mac oem buy cubase 5 studio windows vista business 64 bit iso buy adobe fireworks cs3 buy mappoint 2006 vista 64 bit buy quickbooks enterprise 9.0 price buy visual studio 2008 professional edition microsoft windows 7 home premium buy buy windows vista home premium 64 bit buy word 2007 online adobe cs4 web premium price windows 7 home premium coupon buy photoshop cs2 download buy excel 2007 download quicken 2010 discount autosketch 10 download buy dreamweaver 8 indesign software cost adobe creative suite 4 production premium mac microsoft project 2003 download buy vista ultimate online adobe cs4 design premium cheap buy adobe flash cs3 professional buy adobe cs4 design premium mac windows 7 buy oem download quickbooks premier 2007 microsoft office 2003 download full version adobe contribute pricing purchase windows vista ultimate key download microsoft powerpoint 2003 buy windows 7 home premium cheap download adobe illustrator cs4 purchase windows xp service pack 2 adobe cs3 master collection system requirements buy office onenote 2003 cheapest windows 7 ultimate oem cheapest windows vista buy autodesk lustre cheapest windows 7 ultimate microsoft frontpage price autocad inventor lt suite 2010 download microsoft expression web 3 cheap dreamweaver cs4 download buy adobe master collection cs4 buy norton 360 key adobe flash cs3 for mac windows 7 professional price comparison buy sql server 2008 enterprise edition cheap vista business windows 2003 datacenter licensing buy microsoft money deluxe download after effects cs3 quicken 2010 pricing lightroom price download adobe cs4 design premium mac buy quicken 2009 autodesk lustre price dreamweaver cs4 for mac pcanywhere pricing windows 7 pro sale buy windows 7 64 bit windows 7 ultimate oem price windows 7 ultimate price cheap flash cs3 buy maya 2008 buy adobe dreamweaver cs3 inventor professional suite 2010 buy microsoft office for mac cheap purchase adobe after effects cheap illustrator cs3 buy robohelp 8 photoshop cs3 price microsoft office onenote 2003 download download adobe indesign for mac windows 7 home premium best buy buy corel draw 9 autodesk inventor lt download buy microsoft office enterprise 2007 windows xp discount download adobe fireworks cs4 cheap adobe fireworks adobe contribute cs3 download buy autocad buy word 2003 online ms streets and trips 2010 download acrobat pricing purchase photoshop elements 7 money 2007 home and business corel painter x for mac buy adobe flash cs3 buy windows 7 ultimate retail buy office 2003 pro download autodesk 3ds max 2008 download autodesk inventor lt autocad mechanical best price buy autocad 2010 cheap turbo tax 2009 money 2007 download ms excel 2007 download buy photoshop for mac autodesk 3ds max 2010 trial where can i buy ms office 2003 windows 7 ultimate license buy adobe master suite cs4 adobe premiere pro cs4 price buy turbotax 2006 buy nuendo adobe framemaker price buy quicken 2006 get autocad 2010 purchase windows 7 license online buy microsoft access 2003 download autocad architecture 2008 buy windows 7 ultimate download windows 7 pro download iso download architecture software buy autocad lt adobe photoshop best buy quicken 2010 price cheap powerpoint software norton 360 price comparison photoshop lightroom for mac corel draw coupon code microsoft onenote price buy windows 7 home starter should i buy windows 7 oem or retail buy microsoft money online adobe cs4 master collection discount buy windows 7 student purchase cs3 software where can i buy cubase sx3 buy windows vista business 64 bit microsoft windows vista home premium with sp2 (64 bit) windows 7 64 bit best price how much does windows 7 professional cost buy windows 7 starter buy ms office 2003 online buy pagemaker 7.0 windows 7 home premium cost purchase vista upgrade buy office 2003 professional autodesk autosketch price buy windows vista ultimate cheap adobe cs4 web standard download autodesk architecture suite 3d max 2009 download buy microsoft access 2000 purchase photoshop elements 8 buy windows enterprise buy microsoft money 2005 adobe lightroom cheap encarta premium 2009 download buy ms access 2003 adobe after effects cs4 mac download purchase microsoft excel buy adobe after effects cheap dreamweaver cs4 trial after effects trial buy windows 7 ultimate full get autodesk 3ds max 2010 download inventor 2009 buy microsoft money 2008 download autosketch 10 buy norton ghost 14 buy adobe audition 3.0 buy lightroom download windows vista 64 bit download buy pagemaker 6.5 streets and trips 2010 cost turbotax 2009 deluxe download windows 7 ultimate 32bit system requirements adobe premiere pro mac cheap windows 7 download windows 2003 datacenter download download encarta encyclopedia 2009 framemaker 9 download download adobe flash cs4 nuendo 4 download full buy pagemaker software windows 7 ultimate price uk windows 7 buy license adobe cs3 cheap buy photoshop cs3 cheap buy autodesk inventor professional 2010 3ds max 2010 download buy contribute cs4 how much does microsoft works cost purchase windows 7 ultimate money deluxe download buy adobe premiere pro for mac adobe contribute mac microsoft expression studio 3 price

Plesk & Server Architecture Matt | 12 Nov 2008 01:55 pm

Parse Plesk Maillog, Count Emails Per Domain

I wanted to get a quick count of messages being sent to and from all my domains in plesk.   I wrote this script to get the mail domains from the plesk database.  Then I loop through them and grep a regex against the maillog file.  Since I’m actually using zgrep to look decompress yesterday’s maillog file at the same time I get the counts, it’s a little processor intensive.  It takes about 10 seconds to run through 30 domains in a 5 meg gzipped file.  If I were to gunzip the file first and just grep it, this would go much quicker.  But I’m fine with a 10 second run time and the bonus of not having to trash a decompressed maillog file when I’m done.

Here’s the bash script I’ve saved as mailcount.sh:

#!/bin/sh

MYSQLPASS=`cat /etc/psa/.psa.shadow`

for DOMAIN in `mysql -uadmin -p$MYSQLPASS -e "select distinct domains.name from mail inner join domains on mail.dom_id=domains.id" -B -N psa`

do
echo $DOMAIN `zgrep -c -E "(to|from)=.+@$DOMAIN" /usr/local/psa/var/log/maillog.processed.1.gz`
done

Here’s a version that copies and gunzip’s the maillog before doing any processing.

#!/bin/sh

MYSQLPASS=`cat /etc/psa/.psa.shadow`

# copy the log file before decompress
cp /usr/local/psa/var/log/maillog.processed.1.gz /usr/local/psa/var/log/maillog.processed.1-working.gz &&

# decompress the log working file
gunzip /usr/local/psa/var/log/maillog.processed.1-working.gz

for DOMAIN in `mysql -uadmin -p$MYSQLPASS -e "select distinct domains.name from mail inner join domains on mail.dom_id=domains.id" -B -N psa`
do
echo $DOMAIN `grep -c -E "(to|from)=.+@$DOMAIN" /usr/local/psa/var/log/maillog.processed.1-working`
done

# remove the working log file
rm -f /usr/local/psa/var/log/maillog.processed.1-working &&
echo "file removed"
exit;

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati

3 Responses to “Parse Plesk Maillog, Count Emails Per Domain”

  1. on 21 Jan 2009 at 5:55 pm 1.Juan C Lopez said …

    Hello I try your script and is very interesting the aproach (how ever I got the same number of emails for all domain why), but I see it very REDOUNDANT, why? First you are opening directly a GZiped file, this consumes a Processor time, and memory, as you said it can be done unziping it before), but the problem is that you are doing this process, every time, for each domain in the server, so for a real case (like me), the numbers are:

    122 Total Sites
    8-10mb maillog.gz files
    Time for each site 10-15 secs
    Total time: 21-25 mins

    Im not a SHELL programer so I cant write the script (I did’n even know that you can access MySQL from SHELL :) LOL), but the script sould do something like this:

    1) Store a list of the domains (some how, an array Maybe)
    2) Open the Maillog.gz file
    3) run grep for all the to= and from=
    4) if a domain from the domains list count it (maybe an other literal array in php like $domain['domain.com']++ )
    then at the end print results.

  2. on 21 Jan 2009 at 7:41 pm 2.Juan C Lopez said …

    Me again I just seen the error in the script
    you typed:

    do
    echo $DOMAIN `zgrep -c -E “(to|from)=.+@$domain” /usr/local/psa/var/log/maillog.processed.1.gz`
    done

    and sould be:
    do
    echo $DOMAIN `zgrep -c -E “(to|from)=.+@$DOMAIN” /usr/local/psa/var/log/maillog.processed.1.gz`
    done

    The second domain was lower cased, any way this is still, slow for the reasons i told you before! bye!

  3. on 22 Jan 2009 at 9:48 am 3.Matt said …

    Thanks for the bug fix Juan. I’ve posted a version of this script that copies and decompresses the log file into a working copy and then deletes it when it’s done.

    You’re right, my first version is pretty bad for larger plesk installations. And I think it gets exponentially worse as the log file size increases.

    -Matt

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply


google