From 600182a3a6f81ec48120ccaecb063cf805d35d92 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 31 Aug 2012 11:59:46 +0000 Subject: [PATCH] 2012-08-31 Sergio Martin * include/functions_graph.php operation/agentes/stat_win.php: Added double mode to time compare graphs modes. Separated and overlapped. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6927 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++ pandora_console/include/functions_graph.php | 74 +++++++++++++++---- .../operation/agentes/stat_win.php | 36 ++++++++- 3 files changed, 96 insertions(+), 20 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0ecf0ec308..14038eb43f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-08-31 Sergio Martin + + * include/functions_graph.php + operation/agentes/stat_win.php: Added double mode to + time compare graphs modes. Separated and overlapped. + 2012-06-31 Vanessa Gil * include/functions_api.php: Added functions to api. diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 09e84a7a9d..ae339e0cd1 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -435,7 +435,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, global $warning_min; global $critical_min; - if($compare) { + if($compare !== false) { $series_suffix = '2'; $series_suffix_str = ' ('.__('Previous').')'; // Build the data of the previous period @@ -445,9 +445,19 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_title, $projection, $adapt_key, $compare, $series_suffix, $series_suffix_str); - // Store the chart calculated deleting index, because will be over the current period - $chart_prev = array_values($chart); - $legend_prev = $legend; + switch($compare) { + case 'separated': + // Store the chart calculated + $chart_prev = $chart; + $legend_prev = $legend; + $long_index_prev = $long_index; + break; + case 'overlapped': + // Store the chart calculated deleting index, because will be over the current period + $chart_prev = array_values($chart); + $legend_prev = $legend; + break; + } } // Build the data of the current period @@ -460,7 +470,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, return $data_returned; } - if($compare) { + if($compare === 'overlapped') { $i = 0; foreach($chart as $k=>$v) { $chart[$k] = array_merge($v,$chart_prev[$i]); @@ -477,11 +487,24 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => $config['homeurl'] . "/images/logo_vertical_water.png"); - // Color commented not to restrict serie colors - return area_graph($flash_chart, $chart, $width, $height, $color, $legend, - $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, - $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, - $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key); + if($compare === 'separated') { + return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, + $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, + $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, + $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key). + '
'. + area_graph($flash_chart, $chart_prev, $width, $height/2, $color, $legend_prev, + $long_index_prev, "images/image_problem.opaque.png", "", $unit, $homeurl, + $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, + $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key); + } + else { + // Color commented not to restrict serie colors + return area_graph($flash_chart, $chart, $width, $height, $color, $legend, + $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, + $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, + $series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key); + } } function graph_get_formatted_date($timestamp, $format1, $format2) { @@ -2182,22 +2205,41 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, global $legend; global $long_index; - if($compare) { + if($compare !== false) { $series_suffix = '2'; $series_suffix_str = ' ('.__('Previous').')'; // Build the data of the previous period grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only, $date-$period, $series_suffix, $series_suffix_str); - // Store the chart calculated as previous - $chart_prev = $chart; - $legend_prev = $legend; - $long_index_prev = $long_index; + switch($compare) { + case 'separated': + // Store the chart calculated + $chart_prev = $chart; + $legend_prev = $legend; + $long_index_prev = $long_index; + break; + case 'overlapped': + // Store the chart calculated deleting index, because will be over the current period + $chart_prev = array_values($chart); + $legend_prev = $legend; + break; + } } grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only, $date); + if($compare === 'overlapped') { + $i = 0; + foreach($chart as $k=>$v) { + $chart[$k] = array_merge($v,$chart_prev[$i]); + $i++; + } + + $legend = array_merge($legend, $legend_prev); + } + if ($only_image) { $flash_chart = false; } @@ -2205,7 +2247,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", 'url' => $config['homeurl'] . "/images/logo_vertical_water.png"); - if($compare) { + if($compare === 'separated') { return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend, $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, $water_mark, diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index f0455fbcc7..1daf940674 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -198,7 +198,18 @@ $label = base64_decode(get_parameter('label', '')); $zoom = get_parameter ("zoom", 1); $baseline = get_parameter ("baseline", 0); $show_events_graph = get_parameter ("show_events_graph", 0); - $time_compare = get_parameter ("time_compare", 0); + $time_compare_separated = get_parameter ("time_compare_separated", 0); + $time_compare_overlapped = get_parameter ("time_compare_overlapped", 0); + + + $time_compare = false; + + if($time_compare_separated) { + $time_compare = 'separated'; + } + else if($time_compare_overlapped) { + $time_compare = 'overlapped'; + } if ($zoom > 1) { $height = $height * ($zoom / 2.1); @@ -386,11 +397,20 @@ $label = base64_decode(get_parameter('label', '')); case 'sparse': ?> - + + + + + + + @@ -417,3 +437,11 @@ $label = base64_decode(get_parameter('label', '')); +