summaryrefslogtreecommitdiff
path: root/FS/FS/svc_port.pm
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-03 06:18:41 +0000
committerlevinse <levinse>2011-02-03 06:18:41 +0000
commit088428e5937c8dff49bafeddd52c1c64a8d6cec6 (patch)
treefbc152446f7c7030e41025dea5c296a8da47e089 /FS/FS/svc_port.pm
parent54fd27780c3b48eb1a05be892f65f26b0daab197 (diff)
torrus misc fixes, RT10574
Diffstat (limited to 'FS/FS/svc_port.pm')
-rw-r--r--FS/FS/svc_port.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/FS/FS/svc_port.pm b/FS/FS/svc_port.pm
index 129fb07..ad92e68 100644
--- a/FS/FS/svc_port.pm
+++ b/FS/FS/svc_port.pm
@@ -254,6 +254,8 @@ sub graph_png {
$start = $opt{start} if $opt{start};
$end = $opt{end} if $opt{end};
+ $end = $now if $end > $now;
+
return 'Invalid date range' if ($start < 0 || $start >= $end
|| $end <= $start || $end < 0 || $end > $now || $start > $now
|| $end-$start > 86400*366 );
@@ -292,8 +294,8 @@ sub graph_png {
foreach my $rec ( @records ) {
push @times, $rec->_date
unless grep { $_ eq $rec->_date } @times;
- push @in, $rec->value if $rec->serviceid =~ /_IN$/;
- push @out, $rec->value if $rec->serviceid =~ /_OUT$/;
+ push @in, $rec->value*8 if $rec->serviceid =~ /_IN$/;
+ push @out, $rec->value*8 if $rec->serviceid =~ /_OUT$/;
}
my $timediff = $times[-1] - $times[0]; # they're sorted ascending
@@ -340,8 +342,14 @@ sub graph_png {
my @data = ( \@times, \@in, \@out );
+
# hardcoded size, colour, etc.
- my $graph = new GD::Graph::mixed(600,360); #600,400
+
+ # don't change width/height other than through here; breaks legend otherwise
+ my $width = 600;
+ my $height = 360;
+
+ my $graph = new GD::Graph::mixed($width,$height);
$graph->set(
types => ['area','lines'],
dclrs => ['green','blue'],
@@ -364,6 +372,7 @@ sub graph_png {
my $value = shift;
$self->_format_bandwidth($value,1);
},
+ y_tick_number => 'auto',
y_label => 'bps',
legend_placement => 'BR',
lg_cols => 1,
@@ -389,9 +398,9 @@ sub graph_png {
return "graph error: ".$graph->error unless($gd);
my $black = $gd->colorAllocate(0,0,0);
- $gd->string(gdMediumBoldFont,50,285,
+ $gd->string(gdMediumBoldFont,50,$height-35,
"Current: $in_curr Average: $in_avg Maximum: $in_max Minimum: $in_min",$black);
- $gd->string(gdMediumBoldFont,50,305,
+ $gd->string(gdMediumBoldFont,50,$height-15,
"Current: $out_curr Average: $out_avg Maximum: $out_max Minimum: $out_min",$black);
return $gd->png;