From cdbe314418c2861807945f9412234886621fed1f Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Mon, 27 Feb 2012 16:20:28 +0000 Subject: [PATCH] 2012-02-27 Juan Manuel Ramon * include/functions_graph.php: Added avg_only option to boolean graphs, string graphs have more space between elements in legend, added units to all graphs. * include/graphs/functions_fsgraph.php: Added unit to flash chart of type 2D column. * include/graphs/fgraph.php: Added unit to static version. * include/functions_forecast.php: Fixed division by zero in projection graphs when all data is zero. * operation/agentes/stat_win.php: Added avg_only option for boolean graph. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5653 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++++ .../include/functions_forecast.php | 7 ++-- pandora_console/include/functions_graph.php | 35 ++++++++++++++----- pandora_console/include/graphs/fgraph.php | 2 +- .../include/graphs/functions_fsgraph.php | 4 +-- .../operation/agentes/stat_win.php | 2 +- 6 files changed, 48 insertions(+), 15 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1e78d7ce9d..8aaaf15a3a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-02-27 Juan Manuel Ramon + + * include/functions_graph.php: Added avg_only option to boolean + graphs, string graphs have more space between elements in legend, + added units to all graphs. + * include/graphs/functions_fsgraph.php: Added unit to flash chart + of type 2D column. + * include/graphs/fgraph.php: Added unit to static version. + * include/functions_forecast.php: Fixed division by zero in + projection graphs when all data is zero. + * operation/agentes/stat_win.php: Added avg_only option for boolean + graph. + 2012-02-27 Vanessa Gil * godmode/agentes/agent_template.php: Fixed bug: values 'max_warning', diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index d57299a339..27dfee3d97 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -105,7 +105,10 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe // Linear correlation coefficient: $avg_x = $cont/$sum_xi; - $avg_y = $cont/$sum_yi; + if ($sum_yi != 0) + $avg_y = $cont/$sum_yi; + else + $avg_y = 0; $covariance = $sum_xi_yi/$cont; $dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x)); $dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y)); @@ -189,7 +192,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe } // Using this function for prediction_date if ($prediction_period == false){ - // This statements stop the prediction when interval is greater than 4 years + // These statements stop the prediction when interval is greater than 4 years if ($current_ts - $last_timestamp >= 126144000){ return false; } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index aa38f4541c..6149c5661f 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -363,7 +363,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, // Color commented not to restrict serie colors return area_graph($flash_chart, $chart, $width, $height, '' /*$color*/ ,$legend, - $long_index, "images/image_problem.opaque.png", "", "", $homeurl, + $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], $unit, $ttl); } @@ -1855,6 +1855,11 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, } graphic_error (); } + + if (empty($unit_name)){ + $unit = modules_get_unit($agent_module_id); + }else + $unit = $unit_name; // Data iterator $j = 0; @@ -1934,8 +1939,12 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, // Data and zeroes (draw a step) if ($zero == 1 && $count > 0) { - $chart[$timestamp]['sum'] = $total; - $chart[$timestamp + 1] = array ('sum' => 0, + if ($avg_only) { + $chart[$timestamp]['sum'] = $total; + } + else { + $chart[$timestamp]['sum'] = $total; + $chart[$timestamp + 1] = array ('sum' => 0, //'count' => 0, //'timestamp_bottom' => $timestamp, //'timestamp_top' => $timestamp + $interval, @@ -1943,6 +1952,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, 'max' => 0, 'event' => $event_value, 'alert' => $alert_value); + } $previous_data = 0; // Just zeros } else if ($zero == 1) { @@ -1964,8 +1974,10 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, //$chart[$timestamp]['count'] = 0; //$chart[$timestamp]['timestamp_bottom'] = $timestamp; //$chart[$timestamp]['timestamp_top'] = $timestamp + $interval; - $chart[$timestamp]['min'] = 0; - $chart[$timestamp]['max'] = 0; + if (!$avg_only){ + $chart[$timestamp]['min'] = 0; + $chart[$timestamp]['max'] = 0; + } if($show_events) { $chart[$timestamp]['event'] = $event_value; } @@ -2057,9 +2069,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, } return area_graph($flash_chart, $chart, $width, $height, $color, $legend, - $long_index, "images/image_problem.opaque.png", "", "", $homeurl, + $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size'], ""); + $config['fontpath'], $config['font_size'], $unit); } @@ -2415,6 +2427,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, } } + if (empty($unit_name)){ + $unit = modules_get_unit($agent_module_id); + } + else + $unit = $unit_name; ///////////////////////////////////////////////////////////////////////////////////////// $color = array(); @@ -2434,9 +2451,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, $legend = null; return vbar_graph($flash_chart, $chart, $width, $height, $color, - $legend, "", "", $homeurl, + $legend, "", $unit, $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", - $config['fontpath'], $config['font_size'], '', true, 1, true); + $config['fontpath'], $config['font_size'], true, true, 1, true); } function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 9f0dfbfb86..30a536b442 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -159,7 +159,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array() $water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $reduce_data_columns = false) { if($flash_chart) { - echo fs_2d_column_chart ($chart_data, $width, $height, $homedir, $reduce_data_columns); + echo fs_2d_column_chart ($chart_data, $width, $height, $homedir, $reduce_data_columns, $yaxisname); } else { $graph = array(); diff --git a/pandora_console/include/graphs/functions_fsgraph.php b/pandora_console/include/graphs/functions_fsgraph.php index 966dac53ab..16af88370a 100755 --- a/pandora_console/include/graphs/functions_fsgraph.php +++ b/pandora_console/include/graphs/functions_fsgraph.php @@ -522,7 +522,7 @@ function fs_2d_pie_chart ($data, $names, $width, $height, $background = "FFFFFF" } // Returns a 2D column chart -function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data_columns = false) { +function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data_columns = false, $yaxisname = '') { if (sizeof ($data) == 0) { return; } @@ -596,7 +596,7 @@ function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data } } - $chart->setChartParams('decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;' + $chart->setChartParams('yAxisName=' . $yaxisname . ';decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : '')); // Return the code diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index e6fc8f29d1..4bcb5fd4d1 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -164,7 +164,7 @@ echo "
"; switch ($graph_type) { case 'boolean': echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, 1, false, $date, false, $urlImage); + $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage); echo '


'; if ($show_events_graph) echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);