Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: exim4 and mailgraph
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
andyknownasabu
Apprentice
Apprentice


Joined: 06 Feb 2003
Posts: 281
Location: Zurich, Switzerland

PostPosted: Sat Jul 08, 2006 11:20 am    Post subject: HOWTO: exim4 and mailgraph Reply with quote

Hi folks,

this morning I wanted to get mailgraph (which is originally intended for Postfix/Sendmail) to work as I wasn't able to find a comparable tool for exim4.

If someone would like to provide a nice ebuild for this please post it to bugzilla (bugs.gentoo.org) and a reference in this thread.

Anyway: Have fun! :-)

Step 0:
Install apache(2) with perl/cgi support and configure it according to your needs (not covered in this HOWTO).

Step 1:
Install the dependencies:
Code:
emerge Date-Calc File-Tail rrdtool


Step 2:
Download the mailgraph_1.4exim-1_all.deb Debian package from http://www.postica.com/software/mailgraph/

Step 3:
Create the mailgraph user/group and add the mailgraph user to the mail group:
Code:
useradd mailgraph
groupadd mailgraph
usermod -g mailgraph -G mail mailgraph


Step 4:
Use (as I did) mc with its dpkg plugin to extract the following files/directories from the Debian package to the appropriate target directories and set permissions (to minimize the impact of this manual = non-portage approach on the system I didn't include the docs here):
Code:
CONTENTS/usr/lib/cgi-bin/mailgraph.cgi -> /var/www/localhost/cgi-bin/mailgraph.cgi
CONTENTS/usr/sbin/mailgraph.pl -> /usr/sbin/mailgraph.pl

Code:
cd /var/lib/
mkdir mailgraph
chown mailgraph:mailgraph mailgraph


Step 5:
Create the following file as /etc/conf.d/mailgraph:
Code:
# Location of logfile that exim logs to.
# mailgraph defaults to /var/log/syslog if unspecified
MG_EXIM_LOG="/var/log/exim/mail.log"

# Specify any extra options here.
# If MG_EXIM_LOG is in metalog format, add "-t metalog" to MG_OPTS
#MG_OPTS=""


Step 6:
Create the following initscript as /etc/init.d/mailgraph:
Code:
#!/sbin/runscript
# Copyright 2006 Andreas Bulling
# Distributed under the terms of the GNU General Public License v2

daemon=/usr/sbin/mailgraph.pl
rundir=/var/run/mailgraph
datadir=/var/lib/mailgraph
pidfile=$rundir/pid
user=mailgraph

depend() {
        need exim
}

start() {
        ebegin "Starting mailgraph daemon"

        # read exim log messages somewhere other than /var/log/syslog?
        [[ -n "${MG_EXIM_LOG}" ]] && MG_OPTS="${MG_OPTS} -l ${MG_EXIM_LOG}"

        start-stop-daemon --start --quiet --background \
            --chuid "$user" \
            --pidfile "$pidfile" --make-pidfile \
            --exec "$daemon" -- --daemon --daemon-rrd="$datadir" --exim ${MG_OPTS}

        eend ${?}
}

stop() {
        ebegin  "Stopping mailgraph daemon"

        start-stop-daemon --stop --pidfile "$pidfile" &&
            rm -f "$pidfile"

        eend ${?}
}

This script doesn't work at the moment - if you know how to fix it please let me know ;)

Instead you can add the following line to /etc/conf.d/local.start
to have mailgraph started automatically at boot time:

Code:
/usr/bin/perl -w /usr/sbin/mailgraph.pl -l /var/log/exim/main.log -d --daemon-rrd=/var/lib/mailgraph --exim


Step 7:
Create the directory /var/run/mailgraph and set appropriate permissions:
Code:
cd /var/run/
mkdir mailgraph
chown mailgraph:mailgraph mailgraph


Step 8:
Modify the exim configuration file /etc/exim/exim.conf and add appropriate log_message directives in the different acl sections.
The possible values for log_message are:
Code:
SPAM
MALWARE
BAD_ATTACHMENT
MIME_ERROR

For example for the acl_check_data section:
Code:
  deny    message = This message contains a MIME error ($demime_reason)
          demime = *
          condition = ${if >{$demime_errorlevel}{2}{1}{0}}
          log_message = MIME_ERROR

  deny    message = This message has been rejected because it contains a virus or malware ($malware_name)
          demime = *
          malware = */defer_ok
          log_message = MALWARE


Step 9 (final):
Start mailgraph and restart exim:
Code:
/etc/init.d/mailgraph start
/etc/init.d/exim reload

_________________
Please, also have a look at:
Global Marshall Plan Initiative
http://www.globalmarshallplan.org/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum