From fd64ae1054a59d5f4fe15c37f8e21cd61ff6c9a0 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 29 Oct 2013 09:57:12 +0000 Subject: [PATCH] 2013-10-29 Sergio Martin * include/functions_reporting.php: Merge the logic from the pdf reports to have the same results in both sides for incident #314 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8974 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 + .../include/functions_reporting.php | 110 ++++++------------ 2 files changed, 40 insertions(+), 76 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 42f353a8a0..373f944fcb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2013-10-29 Sergio Martin + + * include/functions_reporting.php: Merge the logic from the + pdf reports to have the same results in both sides for + incident #314 + 2013-10-28 Ramon Novoa * install.php: Added some missing ids. diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index d311597d81..1212547898 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3269,7 +3269,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data_graph[__('Unknown')] = 0; $data_graph[__('Plannified downtime')] = 0; - + + $urlImage = ui_get_full_url(false, true, false, false); + $sla_failed = false; $total_SLA = 0; $total_result_SLA = 'ok'; @@ -3287,84 +3289,22 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f } } - //Get the array of the sla values - $data_sla = reporting_get_agentmodule_sla_array ( - $sla['id_agent_module'], - $content['period'], - $sla['sla_min'], - $sla['sla_max'], - $report['datetime'], - $content, - $content['time_from'], - $content['time_to']); - - - if ($data_sla == false) { - $data_sla = array(); - } - //Get the sla_value in % and store it on $sla_value - $data_total = 0; - $data_pass = 0; - foreach ($data_sla as $d) { - switch ($d['data']) { - case 1: - $data_pass += $d['utimestamp']; - $data_total += $d['utimestamp']; - break; - case 2: - $data_pass += $d['utimestamp']; - $data_total += $d['utimestamp']; - break; - case 3: - $data_total += $d['utimestamp']; - break; - case 4: - case 5: - break; - } - } - - if ($data_total == 0) { - $sla_value = 0; - } - else { - $sla_value = ($data_pass / $data_total) * 100; - } - - //Do not show right modules if 'only_display_wrong' is active - if ($content['only_display_wrong'] == 1 && $sla_value >= $sla['sla_limit']) - continue; - - // Calculate general pie graph data - foreach ($data_sla as $d) { - switch ($d['data']) { - case 1: - $data_graph[__('Inside limits')] += $d['utimestamp']; - break; - case 2: - $data_graph[__('On the edge')] += $d['utimestamp']; - break; - case 3: - $data_graph[__('Out of limits')] += $d['utimestamp']; - break; - case 4: - $data_graph[__('Unknown')] += $d['utimestamp']; - break; - case 5: - $data_graph[__('Plannified downtime')] += $d['utimestamp']; - break; - } - } - - $sla_showed[] = $sla; - $sla_showed_values[] = $sla_value; - $sla_data_arrays[] = $data_sla; + $sla_value = reporting_get_agentmodule_sla ($sla['id_agent_module'], $content['period'], + $sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'], + $content['time_to']); if (($config ['metaconsole'] == 1) && defined('METACONSOLE')) { //Restore db connection metaconsole_restore_db(); } + + //Do not show right modules if 'only_display_wrong' is active + if ($content['only_display_wrong'] == 1 && $sla_value >= $sla['sla_limit']) continue; + + $sla_showed[] = $sla; + $sla_showed_values[] = $sla_value; + } // SLA items sorted descending () @@ -3388,14 +3328,32 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $sla ['server_name']; //Metaconsole connection - if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { + if (($config ['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_connect($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } } + //Fill the array data_graph for the pie graph + if ($sla_value === false) { + $data_graph[__('Unknown')]++; + $data_horin_graph[__('Unknown')]['g']++; + } + else if ($sla_value <= ($sla['sla_limit']+10) && $sla_value >= ($sla['sla_limit']-10)) { + $data_graph[__('On the edge')]++; + $data_horin_graph[__('On the edge')]['g']++; + } + else if ($sla_value > ($sla['sla_limit']+10)) { + $data_graph[__('Inside limits')]++; + $data_horin_graph[__('Inside limits')]['g']++; + } + else if ($sla_value < ($sla['sla_limit']-10)) { + $data_graph[__('Out of limits')]++; + $data_horin_graph[__('Out of limits')]['g']++; + } + if ($sla_value === false) { if ($total_result_SLA != 'fail') $total_result_SLA = 'unknown'; @@ -3462,7 +3420,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $dataslice[1] = graph_sla_slicebar ($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $report['datetime'], $content, $content['time_from'], - $content['time_to'], 650, 25, ui_get_full_url(false, false, false, false), 1, $sla_data_arrays[$k], false); + $content['time_to'], 650, 25, $urlImage, 1, false, false); array_push ($tableslice->data, $dataslice); }