linux:email:monitoring:monitoring

email-monitoring

  • create „/var/lib/rrd“
Mailgraph

mailgraph is a very simple mail statistics RRDtool frontend for Postfix that produces daily, weekly, monthly and yearly graphs of received/sent and bounced/rejected mail (SMTP traffic).

usage: mailgraph.pl [*options*]

-h, --help         display this help and exit
-v, --verbose      be verbose about what you do
-V, --version      output version information and exit
-c, --cat          causes the logfile to be only read and not monitored
-l, --logfile f    monitor logfile f instead of /var/log/syslog
-y, --year         starting year of the log file (default: current year)
    --host=HOST    use only entries for HOST (regexp) in syslog
-d, --daemon       start in the background
--daemon-pid=FILE  write PID to FILE instead of /var/run/mailgraph.pid
--daemon-rrd=DIR   write RRDs to DIR instead of /var/log
--daemon-log=FILE  write verbose-log to FILE instead of /var/log/mailgraph.log
--ignore-localhost ignore mail to/from localhost (used for virus scanner)\n";

If -c is not specified, mailgraph will monitor logfile for Postfix log entries
in logfile (/var/log/syslog unless -l is specified).
#! /bin/sh
#
# /etc/init.d/mailgraph
#   and its symbolic  link
# /local/sbin/rcmailgraph
#
### BEGIN INIT INFO
# Provides:          mailgraph
# Required-Start:    $postfix
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 4 6
# Description: mailgraph
### END INIT INFO

MAILGRAPH_BIN=/usr/local/bin/mailgraph

test -x $MAILGRAPH_BIN || { echo "$MAILGRAPH_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }

test -s /etc/sysconfig/mailgraph && \
      . /etc/sysconfig/mailgraph

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
   start)
      echo -n "Starting mailgraph "
      startproc $MAILGRAPH_BIN  -d $([ -n "$MAILLOG_FILE" ] && echo -l $MAILLOG_FILE ) $OPTIONS

      # Remember status and be verbose
      rc_status -v
      ;;
   stop)
      echo -n "Shutting down postgrey "
      killproc -TERM $MAILGRAPH_BIN
      rc_status -v
      ;;
   restart)
      $0 stop
      $0 start
      rc_status
      ;;
   try-restart)
      $0 status
      if test $? = 0; then
         $0 restart
      else
         rc_reset
      fi
      rc_status
      ;;
   status)
      echo -n "Checking for postgrey"
      checkproc $POSTGREY_BIN
      rc_status -v
      ;;
   *)
     echo "Usage: $0 {start|stop|try-restart|restart|status}"
     exit 1
esac
rc_exit
  • create „/etc/sysconfig/mailgraph“:
# Customized setings for mailgraph
# Define nice level for mailgraph
SERVICE_RUN_NICE_LEVEL="+0"

# Specify mail logfile for monitor by mailgraph 
# instead default /var/log/maillog
# for example: /var/log/mail/info

MAILLOG_FILE=/var/log/mail

# 2007-06-21, chhaas:
OPTIONS="--daemon-rrd=/var/lib/rrd --rbl-is-spam --virbl-is-virus"
  • modify „mailgraph.pl“:
--- mailgraph.cgi	2007-08-16 14:52:37.000000000 +0200
+++ mailgraph.cgi.org	2007-03-28 16:49:36.000000000 +0200
@@ -12,19 +12,12 @@ my $VERSION = "1.13";

 my $host = (POSIX::uname())[1];
 my $scriptname = 'mailgraph.cgi';
-# 2007-08-16, chhaas:
-# my $xpoints = 540;
-my $xpoints = 800;
+my $xpoints = 540;
 my $points_per_sample = 3;
 my $ypoints = 160;
-# my $ypoints_err = 96;
-my $ypoints_err = 80
-# 2007-08-16, chhaas:
-# my $rrd = 'mailgraph.rrd'; # path to where the RRD database is
-my $rrd = '/var/lib/rrd/mailgraph.rrd'; # path to where the RRD database is
-# 2007-08-16, chhaas:
-# my $rrd_virus = 'mailgraph_virus.rrd'; # path to where the Virus RRD database is
-my $rrd_virus = '/var/lib/rrd/mailgraph_virus.rrd'; # path to where the Virus RRD database is
+my $ypoints_err = 96;
+my $rrd = 'mailgraph.rrd'; # path to where the RRD database is
+my $rrd_virus = 'mailgraph_virus.rrd'; # path to where the Virus RRD database is
 my $tmp_dir = '/tmp/mailgraph'; # temporary directory where to store the images
 
 my @graphs = (
@@ -196,8 +189,8 @@ a:hover { text-decoration: underline; }
 </head>
 <body>
 HEADER
+
 	print "<h1>Mail statistics for $host</h1>\n";
-        print "<a href=\"postfix-statistics.cgi\">back to postfix-statistics.cgi</a>\n";
 
 	print "<ul id=\"jump\">\n";
 	for my $n (0..$#graphs) {
@@ -271,4 +264,3 @@ sub main()
 }
 
 main;
  • copy the modified mailgraph.cgi to „/srv/www/cgi-bin/“
  • install File::Tail: openSUSE 10.2: perl-file-Tail-0.99.3.rpm


Queuegraph
README for queuegraph

Dependencies: rrdtools, librrds-perl

To install, adjust the path to your rrdtools binaries in queuegraph-rrd.sh

Create a cronjob that runs queuegraph-rrd.sh every minute -- this populates the *.rrd database:

* * * * * /usr/local/bin/queuegraph-rrd.sh

Now put queuegraph.cgi into the cgi-bin directory of your webserver.
chmod 755 queuegraph.cgi
  1. – queuegraph.cgi 2007-08-16 14:53:20.000000000 +0200

+++ queuegraph.cgi.org 2007-07-28 12:36:28.000000000 +0200

@@ -8,22 +8,16 @@
 use RRDs;
 use POSIX qw(uname);
 
-# 2007-08-16, chhaas:
-# my $VERSION = "1.1";
-my $VERSION = "2007-07-28";
+my $VERSION = "1.1";
 
 my $host = (POSIX::uname())[1];
 my $scriptname = 'queuegraph.cgi';
 my $xpoints = 800;
 my $points_per_sample = 3;
 my $ypoints = 160;
-# 2007-08-16, chhaas:
-# my $ypoints_err = 80;
-my $ypoints_err = 96;
-# 2007-08-16, chhaas:
-# my $rrd = '/etc/postfix/mailqueues.rrd'; # path to where the RRD database is
-my $rrd = '/var/lib/rrd/queuegraph.rrd'; # path to where the RRD database is
-my $tmp_dir = '/tmp/queuegraph'; # temporary directory where to store the images
+my $ypoints_err = 80;
+my $rrd = '/etc/postfix/mailqueues.rrd'; # path to where the RRD database is
+my $tmp_dir = '/tmp'; # temporary directory where to store the images
 my $rrdtool_1_0 = ($RRDs::VERSION < 1.199908);
 
 my @graphs = (
@@ -97,7 +91,6 @@ sub print_html()
 HEADER
 
 	print "<H1>Postfix Queue Statistics for $host</H1>\n";
-	print "<a href=\"postfix-statistics.cgi\">back to postfix-statistics.cgi</a>\n";
 	for my $n (0..$#graphs) {
 		print "<H2>$graphs[$n]{title}</H2>\n";
 		print "<P><IMG BORDER=\"0\" SRC=\"$scriptname/queuegraph_${n}.png\" ALT=\"queuegraph\">\n";
@@ -157,4 +150,3 @@ sub main()
 }
 
 main;


  • modify queuegraph-rrd.sh:
  1. – queuegraph-rrd.sh 2007-08-16 15:01:08.000000000 +0200

+++ queuegraph-rrd.sh.org 2007-07-28 13:07:57.000000000 +0200

@@ -15,9 +15,7 @@
 RRDTOOL=`which rrdtool`
 
 # change this to the location you want to store the rrd
-# 2007-08-16, chhaas:
-# RRDFILE=/etc/postfix/mailqueues.rrd
-RRDFILE=/var/lib/rrd/queuegraph.rrd
+RRDFILE=/etc/postfix/mailqueues.rrd
 
 if test ! -x $RRDTOOL ; then
 	echo "ERROR: $RRDTOOL does not exist or is not executable"


Queue.cgi

### Postfix-Monitoring:
* * * * *	root	/usr/local/bin/qshape.pl /var/spool/postfix/active/ > /srv/www/cgi-bin/active
* * * * *	root	/usr/local/bin/qshape.pl /var/spool/postfix/deferred/ > /srv/www/cgi-bin/deferred
* * * * *	root	/usr/local/bin/logtail.pl -f /var/log/mail | egrep "(reject|error|fatal)" | grep -v "verify error" > /srv/www/cgi-bin/errors
  • create in „/srv/www/cgi-bin“ a file „queue.cgi“:
#!/bin/bash
hostname=`hostname`
cat << EOF
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>Queue Statistics for $hostname</TITLE></HEAD>
<BODY>
<H1>Postfix Queue Statistics for $hostname</H1>
<A HREF="queuegraph.cgi">zur&uuml;ck zur &Uuml;bersicht</A>
<H2>Active Queue (gerade in Bearbeitung befindlich)</H2>
<PRE>
EOF
cat active
cat << EOF
</PRE>
<H2>Deferred Queue (verz&ouml;gert wegen Problemen)</H2>
<PRE>
EOF
cat deferred
cat << EOF
</PRE>
<H2>Errors (Fehler, abgewiesene Mails und sonstiges)</H2>
<PRE>
EOF
sed -e "s/</\&lt;/g" -e "s/>/\&gt;/g" errors
cat << EOF
</PRE>
</BODY>
</HTML>
EOF


postfix-statistics.cgi

  • create in „/srv/www/cgi-bin“ a file „postfix-statistics.cgi“:
#!/usr/bin/perl -w

my $VERSION = "2.0";
my $host = (POSIX::uname())[1];
my $scriptname = 'postfix-statistics.cgi';

sub print_html()
{
	print "Content-Type: text/html\n\n";

	print <<HEADER;
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
	<HTML>
	<HEAD>
	<META HTTP-EQUIV="Cache-Control" content="no-cache">
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<META HTTP-EQUIV="Refresh" CONTENT="60">
	<TITLE>Postfix-Statistik von $host</TITLE>
	</HEAD>
	<BODY BGCOLOR="#FFFFFF">
	HEADER
	
	print "<H1>Postfix-Statistik von $host.$domain</H1>\n";
	print "<UL><LI><A HREF=\"mailgraph.cgi\">Mail-Durchsatz</A>\n";
    	print "<LI><A HREF=\"queuegraph.cgi\">Queue-Statistik</A>\n";
	print "<LI><A HREF=\"queue.cgi\">Queue-Details</A>\n";
	print "</UL>\n";
	for my $n (0..$#graphs) {
		print "<H2>$graphs[$n]{title}</H2>\n";
		print "<H3>Queuegraph:</H3>";
		print "<P><IMG BORDER=\"0\" SRC=\"/cgi-bin/queuegraph.cgi/queuegraph_${n}.png\"\n";
		print "<H3>Mailgraph:</H3>";
		print "<P><IMG BORDER=\"0\" SRC=\"/cgi-bin/mailgraph.cgi?${n}-n\">\n";
		print "<H4>Mailgraph-Errors:</H4>";
		print "<P><IMG BORDER=\"0\" SRC=\"/cgi-bin/mailgraph.cgi?${n}-e\">\n";
	}
        #
        # Print a Queue Summary (Amount of messages per domain in queue).
        #
        use strict;
        my $postqueue = "/usr/sbin/postqueue";
        my %count = ();
        open(QUE, "$postqueue -p |") or die $!;
        while(<QUE>) {
           chomp;
           if ( $_ =~ /^\s+.*\@(.*)/ ) {
                 $count{$1}++;
           }
        }
        
        print"\nTOTAL\tTO\n";
        print"-----   ----------------------------------------------------------------\n";
        foreach my $key (reverse sort { $count{$a} <=> $count{$b}} keys %count) {
                print"$count{$key}\t$key\n";
	}

	print <<FOOTER;
	<table border="0" width="400">
	    <tr>
		<td align="left">
			<A href="http://www.arschkrebs.de/postfix/queuegraph">queuegraph</A> $VERSION
			by <A href="http://www.arschkrebs.de/">Ralf Hildebrandt</A>, 
			based on <A href="http://mailgraph.schweikert.ch/">mailgraph</A> 
			by <A href="http://david.schweikert.ch/">David Schweikert</A>
  			<A href="http://www.arschkrebs.de/postfix/scripts/qSummary.pl"qSummary.pl</A>
			by <A mailto="agalvani@zip.net">Andre Galvani</A>
		</td>
		<td ALIGN="right">
		    <a HREF="http://oss.oetiker.ch/rrdtool/"><img border="0" src="http://tobi.oetiker.ch/webtools/rrdtool/.pics/rrdtool.gif" alt="rrdtool" width="120" height="34"></a>
		</td>
	    </tr>
	</table>
	</BODY>
	FOOTER
	}
	
print_html;
}


Pflogsumm

Download from http://jimsun.linxnet.com/postfix_contrib.html
or Patrick Ben Koetter's German localized version from:
http://postfix.state-of-mind.de/patrick.koetter/pflogsumm/
Requirements:

  • Perl
  • Date::Calc; openSUSE 10.2: perl-Date-Calc-5.4-32.rpm
Pflogsumm README

There's not much to installing pflogsumm, so it's all manual.

  1. Unpack the distribution (if you're reading this, you've already
     gotten that far)

  2. Copy or move pflogsumm.pl to some directory from which you'll
     want to execute it.  Maybe rename it to just "pflogsumm."
     Watch the ownerships and permissions.  Make sure it's executable.

     E.g.:

	    cp pflogsumm.pl /usr/local/bin/pflogsumm
	    chown bin:bin /usr/local/bin/pflogsumm
	    chmod 755 /usr/local/bin/pflogsumm

  3. If there's a manual page available (pflogsumm.1), copy that to
     /usr/local/man/man1 or wherever you stash local manpages.  Make
     sure it's world-readable.

     E.g.:

	    cp pflogsumm.1 /usr/local/man/man1/pflogsumm.1
	    chown bin:bin /usr/local/man/man1/pflogsumm.1
	    chmod 644 /usr/local/man/man1/pflogsumm.1

  4. Read the man page (or the top of pflogsumm itself) for usage.

  5. Check the FAQ (pflogsumm-faq.txt)

  6. Configure your cron jobs if you're going to run pflogsumm on an
     automatic, scheduled basis.  There are tips in the manpage and
     the FAQ.

That's about it.

As the manpage and FAQ both note: pflogsumm requires the Date::Calc Perl module.  If you don't have
Date::Calc, don't want to bother installing it and don't care about smtpd stats, you can remove the
code in pflogsumm that requires it.  For your convenience a Perl script, "rem_smtpd_stats_supp.pl", has been 
provided that will do this.  Simply run it in the directory in which pflogsumm was unpacked *before* 
installing pflogsumm.  E.g.:

      perl rem_smtpd_stats_supp.pl

The script will tell you what it's done, if there were any problems, etc.
  • create a symbolic-link from pflogsumm.pl to /ect/cron.daily to get daly reports

Web-interface:

#!/usr/bin/perl -w

use POSIX qw(uname);

my $host = (POSIX::uname())[1];
my $lang = shift;
my $pflog = '/usr/local/bin/pflogsumm.pl';
my $cat = '/bin/cat';
my $maillog = '/var/log/mail';

$output = `$cat $maillog | $pflog -d today`;

print "<br><br><br><hr><H1><a name='teil2'>More Mail Statistics for $host</a></H1>\n";
print "<PRE>$output</PRE>\n";


Postgreyreport

Contrib with Postgrey.



http-monitoring

awstats

openSUSE-package

Squid Analysis Generator (SARG)
Lightsquid
Squid-graph
Sqstat
Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
  • linux/email/monitoring/monitoring.txt
  • Zuletzt geändert: 2017-04-25 14:58
  • von 127.0.0.1