diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index fd3676a9ae..23f85d2f58 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-10-22 Ramon Novoa + + * include/styles/pandora_minimal.css, include/fgraph.php, + include/functions_fsgraph.php, operation/agentes/stat_win.php: Added + support for chart baseline (Enterprise). + 2010-10-22 Raúl Mateos * godmode/db/db_refine.php, godmode/agentes/manage_config_remote.php, diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index 58327d2f66..2a02d48d23 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -38,8 +38,7 @@ else { require_once ($config['homedir'].'/include/functions_reporting.php'); /**#@-*/ } - - +enterprise_include ('include/functions_reporting.php'); set_time_limit (0); //error_reporting (0); @@ -1311,7 +1310,7 @@ function progress_bar ($progress, $width, $height, $mode = 1) { function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure = false, - $date = 0) { + $date = 0, $baseline = 0, $return_data = 0) { global $config; global $graphic_type; @@ -1405,6 +1404,15 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $previous_data = 0; } + // Get baseline data + $baseline_data = array (); + if ($baseline == 1) { + $baseline_data = enterprise_hook ('enterprise_get_baseline', array ($agent_module_id, $period, $width, $height , $title, $unit_name, $date)); + if ($baseline_data === ENTERPRISE_NOT_HOOK) { + $baseline_data = array (); + } + } + // Calculate chart data for ($i = 0; $i < $resolution; $i++) { $timestamp = $datelimit + ($interval * $i); @@ -1475,8 +1483,17 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $chart[$timestamp]['timestamp_top'] = $timestamp + $interval; $chart[$timestamp]['event'] = $event_value; $chart[$timestamp]['alert'] = $alert_value; + $chart[$timestamp]['baseline'] = array_shift ($baseline_data); + if ($chart[$timestamp]['baseline'] == NULL) { + $baseline = 0; + } } + // Return chart data and don't draw + if ($return_data == 1) { + return $chart; + } + // Get min, max and avg (less efficient but centralized for all modules and reports) $min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2); $max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2); @@ -1518,7 +1535,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, // Flash chart $caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value; if (! $graphic_type) { - return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption); + return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline); } $engine = get_graph_engine ($period); @@ -2734,12 +2751,13 @@ $graphic_type = (string) get_parameter ('tipo'); $mode = get_parameter ("mode", 1); $url = get_parameter ("url"); $report_id = (int) get_parameter ("report_id", 0); +$baseline = (int) get_parameter ('baseline', 0); if ($graphic_type) { switch ($graphic_type) { case 'sparse': grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, - $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); + $label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline); break; case 'sparse_mobile': grafico_modulo_sparse_mobile ($id, $period, $draw_events, $width, $height, diff --git a/pandora_console/include/functions_fsgraph.php b/pandora_console/include/functions_fsgraph.php index 64101e166c..0410524974 100644 --- a/pandora_console/include/functions_fsgraph.php +++ b/pandora_console/include/functions_fsgraph.php @@ -131,7 +131,7 @@ function fs_2d_area_chart ($data, $width, $height, $step = 1, $params = '') { } // Returns a Pandora FMS module chart -function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '') { +function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '', $baseline = 0) { global $config; $graph_type = "MSArea2D"; //MSLine is possible also @@ -223,6 +223,14 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti } } + // Baseline chart + if ($baseline == 1) { + $chart->addDataSet(__('Baseline'), 'color=0097BD;alpha=10;showAreaBorder=0;'); + foreach ($data as $value) { + $chart->addChartData($value['baseline']); + } + } + $chart->setChartParams('animation=0;numVDivLines=' . $num_vlines . ';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : '')); $random_number = rand (); diff --git a/pandora_console/include/styles/pandora_minimal.css b/pandora_console/include/styles/pandora_minimal.css index e8cf690f25..c962600f90 100644 --- a/pandora_console/include/styles/pandora_minimal.css +++ b/pandora_console/include/styles/pandora_minimal.css @@ -87,7 +87,7 @@ table, img { position:absolute; margin:0; width:400px; - height:240px; + height:260px; visibility:hidden; filter:alpha(opacity=90); -moz-opacity: 0.90; diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 97a7e4fdba..9cbfde2450 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -117,6 +117,7 @@ $start_date = get_parameter ("start_date", date("Y-m-d")); $draw_events = get_parameter ("draw_events", 0); $graph_type = get_parameter ("type", "sparse"); $zoom = get_parameter ("zoom", 1); +$baseline = get_parameter ("baseline", 0); if ($zoom > 1) { $height = $height * ($zoom / 2.1); @@ -138,7 +139,7 @@ else if ($config['flash_charts'] && $graph_type != "log4x") { switch ($graph_type) { case 'sparse': echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, - $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); + $label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline); break; case 'boolean': echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, @@ -156,7 +157,7 @@ if ($config['flash_charts'] && $graph_type != "log4x") { } } else { - $image = "../../include/fgraph.php?tipo=".$graph_type."&draw_alerts=".$draw_alerts."&draw_events=".$draw_events."&id=".$id."&zoom=".$zoom."&label=".$label."&height=".$height."&width=".$width."&period=".$period."&avg_only=".$avg_only; + $image = "../../include/fgraph.php?tipo=".$graph_type."&draw_alerts=".$draw_alerts."&draw_events=".$draw_events."&id=".$id."&zoom=".$zoom."&label=".$label."&height=".$height."&width=".$width."&period=".$period."&avg_only=".$avg_only."&baseline=".$baseline; $image .= "&date=" . $date; @@ -227,6 +228,10 @@ echo ''.__('Show alerts').''; print_checkbox ("draw_alerts", 1, (bool) $draw_alerts); +echo ''.__('Draw baseline').''; + +print_checkbox ("baseline", 1, (bool) $baseline); + echo ''; print_submit_button ('GO', "submit", false, 'class="sub next"');