[! 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 $dstat = $stat->traffic_stat_day_dist ($rdb, 1); my ($data0, $data1, $data2, $data3, $data4); my $max = 0; foreach my $ref (@$dstat) { push @$data0, $ref->{index} + 1; push @$data1, $ref->{spamcount}; push @$data2, $ref->{count}; push @$data3, $ref->{viruscount}; push @$data4, $ref->{bounces}; $max = $ref->{count} if $ref->{count} > $max; } my @data = ($data0, $data4, $data2, $data3, $data1); my $graph = GD::Graph::lines->new (600, 400); $graph->set( title => sprintf (decode_entities (__("Incoming Mail Distribution (%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')), decode_entities (__('Virus count')), decode_entities (__('Spam count'))); $graph->plot(\@data); $out .= "

"; my $fn = 'day_in.png'; open (TMP, ">$dir$fn") or die "Cannot open $fn for write: $!"; print TMP $graph->gd->png(); close TMP; $out .= "

"; print OUT $out; -]