Description: Add postgrey and greylisting support to mailgraph
- 2015-09-27: correct typo (LP: #1499625)
Author: Alexander Bech
Origin: http://www.bakarasse.de/pages/en/linux/mailgraph.php
Last-Update: 2015-09-27
--- a/mailgraph.cgi
+++ b/mailgraph.cgi
@@ -16,10 +16,11 @@
my $points_per_sample = 3;
my $ypoints = 160;
my $ypoints_err = 96;
+my $ypoints_grey = 96;
my $rrd = '/var/lib/mailgraph/mailgraph.rrd'; # path to where the RRD database is
my $rrd_virus = '/var/lib/mailgraph/mailgraph_virus.rrd'; # path to where the Virus RRD database is
+my $rrd_greylist = '/var/lib/mailgraph/mailgraph_greylist.rrd'; # path to where the Greylist RRD database is
my $tmp_dir = '/var/lib/mailgraph'; # temporary directory where to store the images
-
my @graphs = (
{ title => 'Last Day', seconds => 3600*24, },
{ title => 'Last Week', seconds => 3600*24*7, },
@@ -28,12 +29,14 @@
);
my %color = (
- sent => '000099', # rrggbb in hex
- received => '009900',
- rejected => 'AA0000',
- bounced => '000000',
- virus => 'DDBB00',
- spam => '999999',
+ sent => '000099', # rrggbb in hex
+ received => '009900',
+ rejected => 'AA0000',
+ bounced => '000000',
+ virus => 'DDBB00',
+ spam => '999999',
+ greylisted => '999999',
+ delayed => '006400',
);
sub rrd_graph(@)
@@ -151,6 +154,36 @@
);
}
+sub graph_grey($$)
+{
+ my ($range, $file) = @_;
+ my $step = $range*$points_per_sample/$xpoints;
+ rrd_graph($range, $file, $ypoints_grey,
+ "DEF:greylisted=$rrd_greylist:greylisted:AVERAGE",
+ "DEF:mgreylisted=$rrd_greylist:greylisted:MAX",
+ "CDEF:rgreylisted=greylisted,60,*",
+ "CDEF:dgreylisted=greylisted,UN,0,greylisted,IF,$step,*",
+ "CDEF:sgreylisted=PREV,UN,dgreylisted,PREV,IF,dgreylisted,+",
+ "CDEF:rmgreylisted=mgreylisted,60,*",
+ "AREA:rgreylisted#$color{greylisted}:Greylisted",
+ 'GPRINT:sgreylisted:MAX:total\: %8.0lf msgs',
+ 'GPRINT:rgreylisted:AVERAGE:avg\: %5.2lf msgs/min',
+ 'GPRINT:rmgreylisted:MAX:max\: %4.0lf msgs/min\l',
+
+ "DEF:delayed=$rrd_greylist:delayed:AVERAGE",
+ "DEF:mdelayed=$rrd_greylist:delayed:MAX",
+ "CDEF:rdelayed=delayed,60,*",
+ "CDEF:ddelayed=delayed,UN,0,delayed,IF,$step,*",
+ "CDEF:sdelayed=PREV,UN,ddelayed,PREV,IF,ddelayed,+",
+ "CDEF:rmdelayed=mdelayed,60,*",
+ "LINE2:rdelayed#$color{delayed}:Delayed ",
+ 'GPRINT:sdelayed:MAX:total\: %8.0lf msgs',
+ 'GPRINT:rdelayed:AVERAGE:avg\: %5.2lf msgs/min',
+ 'GPRINT:rmdelayed:MAX:max\: %4.0lf msgs/min\l',
+ );
+}
+
+
sub print_html()
{
print "Content-Type: text/html\n\n";
@@ -180,6 +213,7 @@
print "$graphs[$n]{title}
\n";
print "
\n";
print "
\n";
+ print "
\n";
}
print <