#!/usr/bin/perl
use strict;
use warnings;
use RRDs;
my @graphs = (
{ title => 'Day Graphs', seconds => 3600*24, },
{ title => 'Week Graphs', seconds => 3600*24*7, },
{ title => 'Month Graphs', seconds => 3600*24*31, },
{ title => 'Year Graphs', seconds => 3600*24*365, },
my ($number,$option) = $ARGV[0] =~ /^(\d+)-(\w)$/;
my $uri = $ARGV[1];
my ($xpoints,$ypoints,$points_per_sample) = (); # werte musst Du noch eintragen
# hier noch variablen wie $rrd, %colors,etc. definieren
die "Falscher Aufruf" unless($number && $option && $uri);
my $path = '/meineBilder/';
my $filepath = $path.$uri.'/mailgraph-'.$number.'.png';
if($option eq 'n'){
my $filepath = $path.$uri.'/mailgraph-'.$number.'.png';
graph($filepath,$graphs[$number]->{seconds});
}
elsif($option eq 'e'){
my $filepath = $path.$uri.'/mailgraph-'.$number.'_error.png';
graph_err($filepath,$graphs[$number]->{seconds});
}
#hier die sub graph_err einfuegen
sub graph{
my ($range, $file) = @_;
my $step = $range*$points_per_sample/$xpoints;
rrd_graph($range, $file, $ypoints,
"DEF:sent=$rrd:sent:AVERAGE",
"DEF:msent=$rrd:sent:MAX",
"CDEF:rsent=sent,60,*",
"CDEF:rmsent=msent,60,*",
"CDEF:dsent=sent,UN,0,sent,IF,$step,*",
"CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+",
"AREA:rsent#$color{sent}:Sent ",
'GPRINT:ssent:MAX:total\: %8.0lf msgs',
'GPRINT:rsent:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmsent:MAX:max\: %4.0lf msgs/min\l',
"DEF:recv=$rrd:recv:AVERAGE",
"DEF:mrecv=$rrd:recv:MAX",
"CDEF:rrecv=recv,60,*",
"CDEF:rmrecv=mrecv,60,*",
"CDEF:drecv=recv,UN,0,recv,IF,$step,*",
"CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+",
"LINE2:rrecv#$color{received}:Received",
'GPRINT:srecv:MAX:total\: %8.0lf msgs',
'GPRINT:rrecv:AVERAGE:avg\: %5.2lf msgs/min',
'GPRINT:rmrecv:MAX:max\: %4.0lf msgs/min\l',
);
}