[rrd-users] mailgraph / rpn
Michael Earls
Michael.Earls at cchmc.org
Fri Mar 19 17:37:26 MET 2004
I have some questions in regard to the source code on mailgraph.pl
The problem I am trying to figure out is the $step (
"CDEF:dsent=sent,UN,0,sent,IF,$step,*", ). This looks like $step should
be ($range*3/540,*)
If i try this using php4-rrtool with this as the cdef (
"CDEF:dsent=sent,UN,0,sent,IF,3600*24,*3/540*", )
I get rrd_graph() ERROR: invalid rpn expression
'sent,UN,0,sent,IF,3600*24,*3/540,*'
Thanks,
Michael
Part of Mailgraph.pl Source Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my $host = (POSIX::uname())[1];
my $scriptname = 'mailgraph.cgi';
my $xpoints = 540;
my $points_per_sample = 3;
my $ypoints = 150;
my $ypoints_err = 80;
my $rrd = '/var/cache/mailgraph/mailgraph.rrd'; # path to where the RRD
database is
my $rrd_virus = '/var/cache/mailgraph/mailgraph_virus.rrd'; # path to
where the Virus RRD database is
my $tmp_dir = '/var/cache/mailgraph'; # temporary directory where to
store the images
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 => '009900',
rejected => 'AA0000',
bounced => '000000',
virus => 'DDBB00',
spam => '999999',
);
sub graph($$$)
{
my $range = shift;
my $file = shift;
my $title = shift;
my $step = $range*$points_per_sample/$xpoints;
my ($graphret,$xs,$ys) = RRDs::graph($file,
'--imgformat', 'PNG',
'--width', $xpoints,
'--height', $ypoints,
'--start', "-$range",
'--vertical-label', 'msgs/min',
'--title', $title,
'--lazy',
"DEF:sent=$rrd:sent:AVERAGE",
"DEF:recv=$rrd:recv:AVERAGE",
"DEF:msent=$rrd:sent:MAX",
"DEF:mrecv=$rrd:recv:MAX",
"CDEF:rsent=sent,60,*",
"CDEF:rrecv=recv,60,*",
"CDEF:rmsent=msent,60,*",
"CDEF:rmrecv=mrecv,60,*",
"CDEF:dsent=sent,UN,0,sent,IF,$step,*",
"CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+",
"CDEF:drecv=recv,UN,0,recv,IF,$step,*",
"CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+",
"AREA:rsent#$color{sent}:Sent ",
'GPRINT:ssent:MAX:total\: %8.0lf msgs',
'GPRINT:rsent:AVERAGE:average\: %.2lf msgs/min',
'GPRINT:rmsent:MAX:max\: %.0lf msgs/min\l',
"LINE2:rrecv#$color{received}:Received",
'GPRINT:srecv:MAX:total\: %8.0lf msgs',
'GPRINT:rrecv:AVERAGE:average\: %.2lf msgs/min',
'GPRINT:rmrecv:MAX:max\: %.0lf msgs/min\l',
'HRULE:0#000000',
'COMMENT:\s',
'COMMENT:graph created on '.localtime(time).'\r',
);
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list