[!
use strict;
use HTML::Entities;
use Proxmox::Utils;
use Proxmox::RuleDB;
use Proxmox::HTMLTable;
use Proxmox::HTMLDropDown;
use Proxmox::Statistic;
use MIME::Base64;
use GD::Graph::lines;
!]
[- Execute ('date_selection.epl'); -]
[-
my $dir = '/var/www/proxmox/statistic/graph/';
my $out = "";
my $stat = Proxmox::Statistic->new ($udat{statistic_from}, $udat{statistic_to});
my $rdb = Proxmox::RuleDB->new();
Proxmox::Statistic::update_stats_dailystat ($rdb->{dbh}, $fdat{__cinfo});
my $span = int ((($udat{statistic_to} - $udat{statistic_from}) / $udat{statistic_groups}));
my $dstat = $stat->traffic_stat_graph ($rdb, $span, 0);
my ($data0, $data1, $data2);
my $max = 0;
foreach my $ref (@$dstat) {
push @$data0, $ref->{index} + 1;
push @$data1, $ref->{count};
push @$data2, $ref->{bounces};
$max = $ref->{count} if $ref->{count} > $max;
}
my @data = ($data0, $data2, $data1);
my $graph = GD::Graph::lines->new (600, 400);
$graph->set(
title => sprintf (decode_entities (__("Outgoing Mail Count (%s)")), $udat{statistic_date}),
transparent => 0,
y_max_value => int(($max + 5) * 1.1),
y_min_value => 0,
y_number_format => '%d',
);
$graph->set_legend (decode_entities (__('Bounces')), decode_entities (__('Mail count')));
$graph->plot(\@data);
$out .= "
";
my $fn = 'outgoing.png';
open (TMP, ">$dir$fn") or die "Cannot open $fn for write: $!";
print TMP $graph->gd->png();
close TMP;
$out .= "