# -*- perl -*- package Smokeping::Graphs; use strict; use Smokeping; =head1 NAME Smokeping::Graphs - Functions used in Smokeping for creating graphs =head1 OVERVIEW This module currently only contains the code for generating the 'multi target' graphs. Code for the other graphs will be moved here too in time. =head2 IMPLEMENTATION =head3 get_multi_detail A version of get_detail for multi host graphs where there is data from multiple targets shown in one graph. The look of the graph is modeld after the graphs shown in the overview page, except for the size. =cut sub get_colors ($){ my $cfg = shift; my @colorList = (); my $colorText = $cfg->{Presentation}{colortext}; my $colorBorder = $cfg->{Presentation}{colorborder}; my $colorBackground = $cfg->{Presentation}{colorbackground}; # If graphborders set to no, and no color override, then return default colors as before if (($cfg->{Presentation}{graphborders} eq 'no') && !($colorText||$colorBorder||$colorBackground)) { return '--border', '0', '--color', 'BACK#ffffff00', '--color', 'CANVAS#ffffff00'; }; # If there are any overrides, use them if ($cfg->{Presentation}{graphborders} eq 'no') { push(@colorList, '--border', '0'); }; if ($colorText) { push(@colorList, '--color', "FONT#${colorText}"); }; if ($colorBorder) { push(@colorList, '--color', "FRAME#${colorBorder}"); }; if ($colorBackground) { push(@colorList, '--color', "SHADEA#${colorBackground}"); push(@colorList, '--color', "SHADEB#${colorBackground}"); push(@colorList, '--color', "BACK#${colorBackground}"); push(@colorList, '--color', "CANVAS#${colorBackground}"); }; if (@colorList) { return @colorList[0..$#colorList] }; # Otherwise use rrdtool defaults return } sub get_multi_detail ($$$$;$){ # a) 's' classic with several static graphs on the page # b) 'n' navigator mode with one graph. below the graph one can specify the end time # and the length of the graph. # c) 'a' ajax mode, generate image based on given url and dump in on stdout # my $cfg = shift; my $q = shift; my $tree = shift; my $open = shift; my $mode = shift || $q->param('displaymode') || 's'; my $phys_open = $open; if ($tree->{__tree_link}){ $tree=$tree->{__tree_link}; $phys_open = $tree->{__real_path}; } my @dirs = @{$phys_open}; return "
| ;
$page .= $q->start_form(-method=>'GET', -id=>'range_form')
. "Time range: " . $q->textfield(-name=>'start',-default=>$startstr) . " to ".$q->textfield(-name=>'end',-default=>$endstr) . $q->hidden(-name=>'epoch_start',-id=>'epoch_start',-default=>$start) . $q->hidden(-name=>'epoch_end',-id=>'epoch_end',-default=>time()) . $q->hidden(-name=>'target',-id=>'target' ) . $q->hidden(-name=>'hierarchy',-id=>'hierarchy' ) . $q->hidden(-name=>'displaymode',-default=>$mode ) . " " . $q->submit(-name=>'Generate!') . "
" . $q->end_form(); $page .= "
}."" ); #"
$page .= "
}."" ); #"
$page .= "