2010-09-08 Ramon Novoa <rnovoa@artica.es>

* include/functions_reporting.php,
          operation/reporting/reporting_xml.php: Improved error detection in
          reports.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3226 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2010-09-08 12:00:34 +00:00
parent aee7cc85f3
commit 60e384ed21
3 changed files with 134 additions and 45 deletions

View File

@ -1,3 +1,9 @@
2010-09-08 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php,
operation/reporting/reporting_xml.php: Improved error detection in
reports.
2010-09-07 Sancho Lerena <slerena@artica.es> 2010-09-07 Sancho Lerena <slerena@artica.es>
* pandoradb_data.sql: Fixed typo in data SQL. * pandoradb_data.sql: Fixed typo in data SQL.

View File

@ -74,7 +74,7 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < $min_necessary) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -168,7 +168,7 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 1) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -320,7 +320,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < $min_necessary) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -445,7 +445,7 @@ function get_agentmodule_sla ($id_agent_module, $period = 0, $min_value = 1, $ma
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 2) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -1767,10 +1767,17 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
} }
$data = array (); $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] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'; $data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">';
$data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>'; $data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32" /></p>';
if ($monitor_value !== __('Unknown')) {
$monitor_value = format_numeric (100 - $monitor_value, 2) ; $monitor_value = format_numeric (100 - $monitor_value, 2) ;
}
$data[1] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'; $data[1] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">';
$data[1] .= $monitor_value.' % <img src="images/b_red.png" height="32" width="32" /></p>'; $data[1] .= $monitor_value.' % <img src="images/b_red.png" height="32" width="32" /></p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -1795,7 +1802,12 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $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] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -1843,7 +1855,12 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[1][0] = 2; $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] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -1867,7 +1884,13 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[1][0] = 2; $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] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -2125,7 +2148,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
$ttr = get_agentmodule_ttr ($content['id_agent_module'], $content['period'], $report["datetime"]); $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 (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
@ -2149,7 +2176,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
$tto = get_agentmodule_tto ($content['id_agent_module'], $content['period'], $report["datetime"]); $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 (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
@ -2173,7 +2204,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
$mtbf = get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]); $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 (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
@ -2197,7 +2232,11 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
$mttr = get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]); $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 (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
@ -2229,7 +2268,7 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
FROM tagente_modulo FROM tagente_modulo
WHERE id_agente_modulo = ' . (int) $id_agent_module); WHERE id_agente_modulo = ' . (int) $id_agent_module);
if ($module === false) { if ($module === false) {
return -1; return false;
} }
$critical_min = $module['min_critical']; $critical_min = $module['min_critical'];
@ -2263,7 +2302,7 @@ function get_agentmodule_mtbf ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 2) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -2337,7 +2376,7 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
FROM tagente_modulo FROM tagente_modulo
WHERE id_agente_modulo = ' . (int) $id_agent_module); WHERE id_agente_modulo = ' . (int) $id_agent_module);
if ($module === false) { if ($module === false) {
return -1; return false;
} }
$critical_min = $module['min_critical']; $critical_min = $module['min_critical'];
@ -2371,7 +2410,7 @@ function get_agentmodule_mttr ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 2) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -2444,7 +2483,7 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
FROM tagente_modulo FROM tagente_modulo
WHERE id_agente_modulo = ' . (int) $id_agent_module); WHERE id_agente_modulo = ' . (int) $id_agent_module);
if ($module === false) { if ($module === false) {
return -1; return false;
} }
$critical_min = $module['min_critical']; $critical_min = $module['min_critical'];
@ -2478,7 +2517,7 @@ function get_agentmodule_tto ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 2) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions
@ -2542,7 +2581,7 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
FROM tagente_modulo FROM tagente_modulo
WHERE id_agente_modulo = ' . (int) $id_agent_module); WHERE id_agente_modulo = ' . (int) $id_agent_module);
if ($module === false) { if ($module === false) {
return -1; return false;
} }
$critical_min = $module['min_critical']; $critical_min = $module['min_critical'];
@ -2576,7 +2615,7 @@ function get_agentmodule_ttr ($id_agent_module, $period, $date = 0) {
if ($next_data !== false) { if ($next_data !== false) {
$next_data['utimestamp'] = $date; $next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data); array_push ($interval_data, $next_data);
} else { } else if (count ($interval_data) > 0) {
// Propagate the last known data to the end of the interval // Propagate the last known data to the end of the interval
$next_data = array_pop ($interval_data); $next_data = array_pop ($interval_data);
array_push ($interval_data, $next_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) { if (count ($interval_data) < 2) {
return -1; return false;
} }
// Set initial conditions // Set initial conditions

View File

@ -231,29 +231,57 @@ foreach ($contents as $content) {
case 6: case 6:
case 'monitor_report': case 'monitor_report':
$data["title"] = __('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"]["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; break;
case 7: case 7:
case 'avg_value': case 'avg_value':
$data["title"] = __('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; break;
case 8: case 8:
case 'max_value': case 'max_value':
$data["title"] = __('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; break;
case 9: case 9:
case 'min_value': case 'min_value':
$data["title"] = __('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; break;
case 10: case 10:
case 'sumatory': case 'sumatory':
$data["title"] = __('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; break;
// case 11: // case 11:
// case 'general_group_report': // case 'general_group_report':
@ -506,31 +534,47 @@ foreach ($contents as $content) {
break; break;
case 'TTRT': case 'TTRT':
$ttr = get_agentmodule_ttr ($content['id_agent_module'], $content['period'], $report["datetime"]); $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["title"] = __('TTRT');
$data["objdata"] = format_numeric($ttr); $data["objdata"] = $ttr;
break; break;
case 'TTO': case 'TTO':
$tto = get_agentmodule_tto ($content['id_agent_module'], $content['period'], $report["datetime"]); $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["title"] = __('TTO');
$data["objdata"] = format_numeric($tto); $data["objdata"] = $tto;
break; break;
case 'MTBF': case 'MTBF':
$mtbf = get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]); $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["title"] = __('MTBF');
$data["objdata"] = format_numeric($mtbf); $data["objdata"] = $mtbf;
break; break;
case 'MTTR': case 'MTTR':
$mttr = get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]); $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["title"] = __('MTTR');
$data["objdata"] = format_numeric($mttr); $data["objdata"] = $mttr;
break; break;
} }
xml_array ($data); xml_array ($data);