queuegraph_1.1.1.orig/0000755000175000017500000000000010502106022014167 5ustar conallconallqueuegraph_1.1.1.orig/queuegraph.cgi0000755000175000017500000000776510502106022017043 0ustar conallconall#!/usr/bin/perl -w # queuegraph -- a postfix queue statistics rrdtool frontend # based on mailgraph, which is # copyright (c) 2000-2002 David Schweikert # released under the GNU General Public License use RRDs; use POSIX qw(uname); my $VERSION = "1.1"; my $host = (POSIX::uname())[1]; my $scriptname = 'queuegraph.cgi'; my $xpoints = 800; my $points_per_sample = 3; my $ypoints = 160; my $ypoints_err = 80; my $rrd = '/etc/postfix/mailqueues.rrd'; # path to where the RRD database is my $tmp_dir = '/tmp/queuegraph'; # temporary directory where to store the images my $rrdtool_1_0 = ($RRDs::VERSION < 1.199908); my @graphs = ( { title => 'Day Graph', seconds => 3600*24, }, { title => 'Week Graph', seconds => 3600*24*7, }, { title => 'Month Graph', seconds => 3600*24*31, }, { title => 'Year Graph', seconds => 3600*24*365, }, ); my %color = ( sent => '000099', # rrggbb in hex received => '00FF00', rejected => '999999', bounced => '993399', virus => 'FFFF00', spam => 'FF0000', ); sub graph($$$) { my $range = shift; my $file = shift; my $title = shift; my $step = $range*$points_per_sample/$xpoints; my $date = localtime(time); $date =~ s|:|\\:|g unless $rrdtool_1_0; my ($graphret,$xs,$ys) = RRDs::graph($file, '--imgformat', 'PNG', '--width', $xpoints, '--height', $ypoints, '--start', "-$range", '--end', "-".int($range*0.01), '--vertical-label', 'queuefiles', '--title', $title, '--lazy', $rrdtool_1_0 ? () : ( '--slope-mode' ), "DEF:active=$rrd:active:AVERAGE", "DEF:deferred=$rrd:deferred:AVERAGE", 'LINE2:active#00ff00:Active+Incoming+Maildrop\:', 'GPRINT:active:MAX:Maximum\: %0.0lf ', 'GPRINT:active:AVERAGE:Average\: %0.0lf/min\n', 'LINE1:deferred#0000ff:Deferred\:', 'GPRINT:deferred:MAX:Maximum\: %0.0lf ', 'GPRINT:deferred:AVERAGE:Average\: %0.0lf/min\l', 'HRULE:0#000000', 'COMMENT:\n', 'COMMENT:['.$date.']\r', ); my $ERR=RRDs::error; die "ERROR: $ERR\n" if $ERR; } sub print_html() { print "Content-Type: text/html\n\n"; print < Queue Statistics for $host HEADER print "

Postfix Queue Statistics for $host

\n"; for my $n (0..$#graphs) { print "

$graphs[$n]{title}

\n"; print "

\"queuegraph\"\n"; } print < queuegraph $VERSION by Ralf Hildebrandt, based on mailgraph by David Schweikert FOOTER } sub send_image($) { my $file = shift; -r $file or do { print "Content-Type: text/plain\n\nERROR: can't find $file\n"; exit 1; }; print "Content-Type: image/png\n"; print "Content-Length: ".((stat($file))[7])."\n"; print "\n"; open(IMG, $file) or die; my $data; print $data while read IMG, $data, 1; } sub main() { if($ENV{PATH_INFO}) { my $uri = $ENV{REQUEST_URI}; $uri =~ s/\/[^\/]+$//; $uri =~ s/\//,/g; $uri =~ s/\~/tilde,/g; mkdir $tmp_dir, 0777 unless -d $tmp_dir; mkdir "$tmp_dir/$uri", 0777 unless -d "$tmp_dir/$uri"; my $file = "$tmp_dir/$uri$ENV{PATH_INFO}"; if($ENV{PATH_INFO} =~ /^\/queuegraph_(\d+)\.png$/) { graph($graphs[$1]{seconds}, $file, $graphs[$1]{title}); } else { print "Content-Type: text/plain\n\nERROR: unknown image $ENV{PATH_INFO}\n"; exit 1; } send_image($file); } else { print_html; } } main; queuegraph_1.1.1.orig/queuegraph/0000755000175000017500000000000010502106022016335 5ustar conallconallqueuegraph_1.1.1.orig/queuegraph/count.sh0000755000175000017500000000173410502106022020031 0ustar conallconall#!/bin/sh # $Id: mailqsize,v 1.4 2002/05/07 17:47:30 khera Exp $ # output the number of messages in the incoming, active, and deferred # queues of postfix one per line suitable for use with snmpd/cricket # # mailqsize was originally written by Vivek Khera. All I did was # make it update an rrd. # 2003/01/24 01:19:37 Mike Saunders # I bundled this with a modified mailgraph # 2003/04/14 Ralf Hildebrandz # Change this to the location where your RRD is stored: cd /etc/postfix PATH=/usr/local/rrdtool-1.0.48/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/bin:/usr/sbin: #set -x qdir=`postconf -h queue_directory` active=`find $qdir/incoming $qdir/active $qdir/maildrop -type f -print | wc -l | awk '{print $1}'` deferred=`find $qdir/deferred -type f -print | wc -l | awk '{print $1}'` #printf "active: %d\ndeferred: %d\n" $active $deferred rrdtool update /etc/postfix/mailqueues.rrd "N:$active:$deferred" queuegraph_1.1.1.orig/queuegraph/createrrd.sh0000755000175000017500000000050110502106022020643 0ustar conallconall#!/bin/sh RRDTOOL=/usr/local/rrdtool-1.0.48/bin/rrdtool $RRDTOOL create /etc/postfix/mailqueues.rrd --step 60 \ DS:active:GAUGE:900:0:U \ DS:deferred:GAUGE:900:0:U \ RRA:AVERAGE:0.5:1:20160 \ RRA:AVERAGE:0.5:30:2016 \ RRA:AVERAGE:0.5:60:105120 \ RRA:MAX:0.5:1:1440 \ RRA:MAX:0.5:30:2016 \ RRA:MAX:0.5:60:105120 queuegraph_1.1.1.orig/queuegraph/README0000644000175000017500000000063210502106022017216 0ustar conallconallREADME for queuegraph To install, adjust the path to your rrdtools binaries in count.sh and createrrd.sh Then run createrrd.sh to create the *.rrd database. Create a cronjob that runs count.sh every minute -- this populates the *.rrd database: * * * * * /var/www/html/hauptpostamt.charite.de\:80/mailq_grapher/count.sh # mailq_grapher Now put queuegraph.cgi into the cgi-bin directory of your webserver. queuegraph_1.1.1.orig/queue.cgi0000755000175000017500000000134410502106022016004 0ustar conallconall#!/bin/sh cat << EOF Content-Type: text/html Queue breakdown for mail.charite.de

Postfix Queue Statistics for mail.charite.de

Active Queue (gerade in Bearbeitung befindlich)

EOF
cat active
cat << EOF

Deferred Queue (verzögert wegen Problemen)

EOF
cat deferred
cat << EOF

Errors (Fehler, abgewiesene Mails und sonstiges)

EOF
sed -e "s//\>/g" errors
cat << EOF
EOF