diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a5bfdd4d0a..2f9fb0794a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2010-09-08 Ramon Novoa + + * include/functions_reporting.php, + operation/reporting/reporting_xml.php: Improved error detection in + reports. + 2010-09-07 Sancho Lerena * pandoradb_data.sql: Fixed typo in data SQL. diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index bf51087288..820f632266 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -74,7 +74,7 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -86,7 +86,7 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < $min_necessary) { - return -1; + return false; } // Set initial conditions @@ -168,7 +168,7 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -240,7 +240,7 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -250,7 +250,7 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < 1) { - return -1; + return false; } // Set initial conditions @@ -320,7 +320,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -332,7 +332,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < $min_necessary) { - return -1; + return false; } // Set initial conditions @@ -445,7 +445,7 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -454,7 +454,7 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma } if (count ($interval_data) < 2) { - return -1; + return false; } // Set initial conditions @@ -1767,10 +1767,17 @@ function render_report_html_item ($content, $table, $report, $mini = false) { } $data = array (); - $monitor_value = format_numeric (get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $report["datetime"])); + $monitor_value = get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $report["datetime"]); + if ($monitor_value === false) { + $monitor_value = __('Unknown'); + } else { + $monitor_value = format_numeric ($monitor_value); + } $data[0] = '

'; $data[0] .= $monitor_value.' %

'; - $monitor_value = format_numeric (100 - $monitor_value, 2) ; + if ($monitor_value !== __('Unknown')) { + $monitor_value = format_numeric (100 - $monitor_value, 2) ; + } $data[1] = '

'; $data[1] .= $monitor_value.' %

'; array_push ($table->data, $data); @@ -1795,7 +1802,12 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[2][0] = 3; - $value = format_numeric (get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $report["datetime"])); + $value = get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $report["datetime"]); + if ($value === false) { + $value = __('Unknown'); + } else { + $value = format_numeric ($value); + } $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -1843,7 +1855,12 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[1][0] = 2; - $value = format_numeric (get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $report["datetime"])); + $value = get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $report["datetime"]); + if ($value === false) { + $value = __('Unknown'); + } else { + $value = format_numeric ($value); + } $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -1867,7 +1884,13 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[1][0] = 2; - $value = format_numeric (get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $report["datetime"])); + $value = get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $report["datetime"]); + if ($value === false) { + $value = __('Unknown'); + } else { + $value = format_numeric ($value); + } + $data[0] = '

'.$value.'

'; array_push ($table->data, $data); @@ -2125,7 +2148,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[2][0] = 3; $ttr = get_agentmodule_ttr ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($ttr != 0) $ttr = human_time_description_raw ($ttr); + if ($ttr === false) { + $ttr = __('Unknown'); + } else if ($ttr != 0) { + $ttr = human_time_description_raw ($ttr); + } $data = array (); $table->colspan[2][0] = 3; @@ -2149,7 +2176,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[2][0] = 3; $tto = get_agentmodule_tto ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($tto != 0) $tto = human_time_description_raw ($tto); + if ($tto === false) { + $tto = __('Unknown'); + } else if ($tto != 0) { + $tto = human_time_description_raw ($tto); + } $data = array (); $table->colspan[2][0] = 3; @@ -2173,7 +2204,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[2][0] = 3; $mtbf = get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($mtbf != 0) $mtbf = human_time_description_raw ($mtbf); + if ($mtbf === false) { + $mtbf = __('Unknown'); + } else if ($mtbf != 0) { + $mtbf = human_time_description_raw ($mtbf); + } $data = array (); $table->colspan[2][0] = 3; @@ -2197,7 +2232,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) { $data = array (); $table->colspan[2][0] = 3; $mttr = get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($mttr != 0) $mttr = human_time_description_raw ($mttr); + if ($mttr === false) { + $mttr = __('Unknown'); + } else if ($mttr != 0) { + $mttr = human_time_description_raw ($mttr); + } $data = array (); $table->colspan[2][0] = 3; @@ -2229,7 +2268,7 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) { FROM tagente_modulo WHERE id_agente_modulo = ' . (int) $id_agent_module); if ($module === false) { - return -1; + return false; } $critical_min = $module['min_critical']; @@ -2263,7 +2302,7 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -2272,7 +2311,7 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < 2) { - return -1; + return false; } // Set initial conditions @@ -2337,7 +2376,7 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) { FROM tagente_modulo WHERE id_agente_modulo = ' . (int) $id_agent_module); if ($module === false) { - return -1; + return false; } $critical_min = $module['min_critical']; @@ -2371,7 +2410,7 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -2380,7 +2419,7 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < 2) { - return -1; + return false; } // Set initial conditions @@ -2444,7 +2483,7 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) { FROM tagente_modulo WHERE id_agente_modulo = ' . (int) $id_agent_module); if ($module === false) { - return -1; + return false; } $critical_min = $module['min_critical']; @@ -2478,7 +2517,7 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -2487,7 +2526,7 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < 2) { - return -1; + return false; } // Set initial conditions @@ -2542,7 +2581,7 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) { FROM tagente_modulo WHERE id_agente_modulo = ' . (int) $id_agent_module); if ($module === false) { - return -1; + return false; } $critical_min = $module['min_critical']; @@ -2576,7 +2615,7 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) { if ($next_data !== false) { $next_data['utimestamp'] = $date; array_push ($interval_data, $next_data); - } else { + } else if (count ($interval_data) > 0) { // Propagate the last known data to the end of the interval $next_data = array_pop ($interval_data); array_push ($interval_data, $next_data); @@ -2585,7 +2624,7 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) { } if (count ($interval_data) < 2) { - return -1; + return false; } // Set initial conditions diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 45a6af424a..aeeaa103e0 100644 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -231,29 +231,57 @@ foreach ($contents as $content) { case 6: case 'monitor_report': $data["title"] = __('Monitor report'); - $monitor_value = format_numeric (get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime)); + $monitor_value = get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $datetime); + if ($monitor_value === false) { + $monitor_value = __('Unknown'); + } else { + $monitor_value = format_numeric ($monitor_value); + } $data["objdata"]["good"] = $monitor_value; - $data["objdata"]["bad"] = format_numeric (100 - $monitor_value, 2); + if ($monitor_value !== __('Unknown')) { + $monitor_value = format_numeric (100 - $monitor_value); + } + $data["objdata"]["bad"] = $monitor_value; break; case 7: case 'avg_value': $data["title"] = __('Avg. Value'); - $data["objdata"] = format_numeric (get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $datetime)); + $data["objdata"] = get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $datetime); + if ($data["objdata"] === false) { + $data["objdata"] = __('Unknown'); + } else { + $data["objdata"] = format_numeric ($data["objdata"]); + } break; case 8: case 'max_value': $data["title"] = __('Max. Value'); - $data["objdata"] = format_numeric (get_agentmodule_data_max ($content['id_agent_module'], $content['period'], $datetime)); + $data["objdata"] = get_agentmodule_data_max ($content['id_agent_module'], $content['period'], $datetime); + if ($data["objdata"] === false) { + $data["objdata"] = __('Unknown'); + } else { + $data["objdata"] = format_numeric ($data["objdata"]); + } break; case 9: case 'min_value': $data["title"] = __('Min. Value'); - $data["objdata"] = format_numeric (get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $datetime)); + $data["objdata"] = get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $datetime); + if ($data["objdata"] === false) { + $data["objdata"] = __('Unknown'); + } else { + $data["objdata"] = format_numeric ($data["objdata"]); + } break; case 10: case 'sumatory': $data["title"] = __('Sumatory'); - $data["objdata"] = format_numeric (get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $datetime)); + $data["objdata"] = get_agentmodule_data_sum ($content['id_agent_module'], $content['period'], $datetime); + if ($data["objdata"] === false) { + $data["objdata"] = __('Unknown'); + } else { + $data["objdata"] = format_numeric ($data["objdata"]); + } break; // case 11: // case 'general_group_report': @@ -506,31 +534,47 @@ foreach ($contents as $content) { break; case 'TTRT': $ttr = get_agentmodule_ttr ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($ttr != 0) $ttr = human_time_description_raw ($ttr); - + if ($ttr === false) { + $ttr = __('Unknown'); + } else if ($ttr != 0) { + $ttr = human_time_description_raw ($ttr); + } + $data["title"] = __('TTRT'); - $data["objdata"] = format_numeric($ttr); + $data["objdata"] = $ttr; break; case 'TTO': $tto = get_agentmodule_tto ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($tto != 0) $tto = human_time_description_raw ($tto); + if ($tto === false) { + $tto = __('Unknown'); + } else if ($tto != 0) { + $tto = human_time_description_raw ($tto); + } $data["title"] = __('TTO'); - $data["objdata"] = format_numeric($tto); + $data["objdata"] = $tto; break; case 'MTBF': $mtbf = get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($mtbf != 0) $mtbf = human_time_description_raw ($mtbf); + if ($mtbf === false) { + $mtbf = __('Unknown'); + } else if ($mtbf != 0) { + $mtbf = human_time_description_raw ($mtbf); + } $data["title"] = __('MTBF'); - $data["objdata"] = format_numeric($mtbf); + $data["objdata"] = $mtbf; break; case 'MTTR': $mttr = get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]); - if ($mttr != 0) $mttr = human_time_description_raw ($mttr); + if ($mttr === false) { + $mttr = __('Unknown'); + } else if ($mttr != 0) { + $mttr = human_time_description_raw ($mttr); + } $data["title"] = __('MTTR'); - $data["objdata"] = format_numeric($mttr); + $data["objdata"] = $mttr; break; } xml_array ($data);