MIKE YRABEDRA wrote:
on 6/13/05 8:01 AM, Ronan McGlue at [EMAIL PROTECTED] wrote:


MIKE YRABEDRA wrote:

on 6/13/05 6:07 AM, Bart Verwilst at [EMAIL PROTECTED] wrote:



Hi

Try MailGraph :) That's what I'm using for my servers..
Google for mailgraph, first hit :)

See ya



Looks good, but I think I passed it over because I am not using postfix. I
am using Communigate Pro.

However, my spamd writes to it's own log so maybe it will still work.

Only one way to find out ;-)

you could also try gnu plot... i was also looking for a 'drop in'
graphing program and found GNUplot was exactly what i wanted...

i use sa-stats.pl to read the log file then simply grep on the day >
pipe to a file and plot on the basis of that. v simple, clean and pretty :)
ill show u the script if u want.. its only 10 or so lines long :)
easy

Ronan



That would be awesome!  Feel free to contact me off-list if you want. :-)>

ive no probs showing the clunkyness of my bash'ing ability... just dont comoment if its negative :D

feel free to note the name of the spamd server ;)

i have two scripts... one for hourly 'live' stats and one for 'yesterday'

LIVE
=====

[EMAIL PROTECTED]:/home/ronan/stats# cat /etc/cron.hourly/live.sh
#!/bin/bash

# to be run every hour to give live updated stats

hour=`date +%k`
#let "hour -= 1"
date=`date +%d/%m/%y`
/usr/local/bin/sa-stats.pl -l /var/log/maillog -s 'today midnight' 1> /home/ronan/stats/spam_live.txt /bin/grep "%" /home/ronan/stats/spam_live.txt |egrep -v ":"|awk '{print $2,$3+$6,$3,$6}' > /home/ronan/stats/daily_live.tmp cat /home/ronan/stats/daily_live.tmp | head -$hour > /home/ronan/stats/daily_live.txt

cat > /home/ronan/stats/gnuplot.live << EOFEOF
set terminal png small color picsize 1000 200
set grid
set title "Hourly Live Mail Stats (GMT)"
set xtics 0,1,23
set time
set output '/var/www/htdocs/spam_live.png'
set xr [0:23]
plot \
'/home/ronan/stats/daily_live.txt' using 1:2 title 'total' with lines, \
'/home/ronan/stats/daily_live.txt' using 1:3 title 'tagged spam' with lines, \
'/home/ronan/stats/daily_live.txt' using 1:4 title 'tagged ham' with lines
EOFEOF

gnuplot /home/ronan/stats/gnuplot.live

#rm /home/ronan/stats/spam_live.txt /home/ronan/stats/daily_live.tmp /home/ronan/stats/daily_live.txt /home/ronan/stats/gnuplot.live


DAILY
=====
[EMAIL PROTECTED]:/home/ronan/stats# cat /etc/cron.daily/sa.sh
#!/bin/bash

# to be run after 12 at night so that the day -1 is correct

suff=`date +%m_%Y`
day=`date +%e`
let "day -= 1"
/usr/local/bin/sa-stats.pl -l /var/log/maillog.1 -s 'yesterday midnight' 1> /home/ronan/stats/spam${suff}_${day}.txt /bin/grep "%" /home/ronan/stats/spam${suff}_${day}.txt|/bin/egrep -v ":" |awk '{print $2,$3+$6,$3,$6}' > /home/ronan/stats/daily${suff}_${day}.txt
cat > /home/ronan/stats/gnuplot.${suff}_${day} << EOFEOF
set terminal png small color picsize 1000 200
set time
set grid
set xtics 0,1,23
set title "Spam vs Ham for ${day}_${suff}"
set output '/var/www/htdocs/spam${suff}_${day}.png'
set xr [0:23]
plot \
'/home/ronan/stats/daily${suff}_${day}.txt' using 1:2 title 'Total Messages' with lines, \ '/home/ronan/stats/daily${suff}_${day}.txt' using 1:3 title 'tagged spam' with lines, \ '/home/ronan/stats/daily${suff}_${day}.txt' using 1:4 title 'tagged ham' with lines
EOFEOF
gnuplot /home/ronan/stats/gnuplot.${suff}_${day}

cat > /var/www/htdocs/index.html << HTMLEOF
<HTML><BODY><table><tr><td>
<img src="spam_live.png" alt="live spam stats">
</td></tr><tr><td>
<img src="spam${suff}_${day}.png" alt="yesterdays spam stats">
</td></tr></table></BODY></HTML>
HTMLEOF

HAM=`/bin/grep -i "total ham" /home/ronan/stats/spam${suff}_${day}.txt|awk '{print $5}'` SPAM=`/bin/grep -i "total spam" /home/ronan/stats/spam${suff}_${day}.txt|awk '{print $5}'`
cat >> /home/ronan/stats/weekly.totals << STATS
${suff}_${day},$HAM,$SPAM
STATS
#rm -f /home/ronan/stats/spam${suff}_${day}.txt /home/ronan/stats/daily${suff}_${day}.txt /home/ronan/stats/gnuplot.${suff}_${day}


HTH
Ronan

-Mike




--
========

Regards

Ronan McGlue
Info. Services
QUB

Reply via email to