From: Eric Bollengier Date: Sat, 26 Aug 2006 17:43:31 +0000 (+0000) Subject: ebl add more graph type X-Git-Tag: Release-2.0.0~539 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c5ae31038504917965da68c73bac9d20faeeda72;p=bacula%2Fbacula ebl add more graph type git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3377 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bgraph.pl b/gui/bweb/cgi/bgraph.pl index 63750b530e..ba5bd36872 100755 --- a/gui/bweb/cgi/bgraph.pl +++ b/gui/bweb/cgi/bgraph.pl @@ -151,6 +151,24 @@ sub make_tab return ($date, $ret); } +sub make_tab_sum +{ + my ($all_row) = @_; + + my $i=0; + my $last_date=0; + + my $ret = {}; + + foreach my $row (@$all_row) { + $ret->{date}->[$i] = $row->[0]; + $ret->{nb}->[$i] = $row->[1]; + $i++; + } + + return ($ret); +} + if ($graph eq 'job_size') { my $query = " @@ -304,5 +322,59 @@ $limitq $obj->set_legend(keys %$ret); } print $obj->plot([$d, values %$ret])->png; + + +# number of job per day/hour +} elsif ($graph =~ /^job_(count|sum|avg)_((p?)(day|hour|month))$/) { + my $t = $1; + my $d = uc($2); + my $per_t = $3; + my ($limit, $label) = $bweb->get_limit(age => $arg->{age}, + limit => $arg->{limit}, + offset=> $arg->{offset}, + groupby => "A", + ); + my @arg; # arg for plotting + + if (!$per_t) { # much better aspect + $gtype = 'lines'; + } else { + push @arg, ("x_number_format" => undef, + "x_min_value" => 0, + ); + } + + if ($t eq 'sum' or $t eq 'avg') { + push @arg, ('y_number_format' => \&Bweb::human_size); + } + + my $query = " +SELECT + " . ($per_t?"":"UNIX_TIMESTAMP") . "(" . $bweb->{sql}->{"STARTTIME_$d"} . ") AS A, + $t(JobBytes) AS nb +FROM Job, Client, FileSet +WHERE Job.ClientId = Client.ClientId + AND Job.FileSetId = FileSet.FileSetId + AND Job.Type = 'B' + $clientq + $statusq + $filesetq + $levelq + $jobnameq +$limit +"; + + print STDERR $query if ($debug); + + my $obj = get_graph('title' => "Job $t : $arg->{jclients}/$arg->{jjobnames}", + 'y_label' => $t, + 'y_min_value' => 0, + @arg, + ); + + my $all = $dbh->selectall_arrayref($query) ; + my ($ret) = make_tab_sum($all); + + print $obj->plot([$ret->{date}, $ret->{nb}])->png; } diff --git a/gui/bweb/tpl/graph.tpl b/gui/bweb/tpl/graph.tpl index ffab0f3976..5ad94e1aa0 100644 --- a/gui/bweb/tpl/graph.tpl +++ b/gui/bweb/tpl/graph.tpl @@ -68,10 +68,22 @@

Type