2012-06-22 Sergio Martin <sergio.martin@artica.es>

* include/functions_reporting.php: Improved several 
	parts of SLA reports. Add icons to criticity, etc.
	
	* include/functions_api.php: Fixed bug in get events
	api function remaning function
	
	* godmode/reporting/graph_builder.graph_editor.php: Increase
	the size of little combo boxes in combined graphs editor

	Merged from 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6679 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-06-22 12:19:05 +00:00
parent 0e205b15a4
commit af1bfb2a6a
4 changed files with 138 additions and 76 deletions

View File

@ -1,3 +1,16 @@
2012-06-22 Sergio Martin <sergio.martin@artica.es>
* include/functions_reporting.php: Improved several
parts of SLA reports. Add icons to criticity, etc.
* include/functions_api.php: Fixed bug in get events
api function remaning function
* godmode/reporting/graph_builder.graph_editor.php: Increase
the size of little combo boxes in combined graphs editor
Merged from 4.0.2
2012-06-22 Miguel de Dios <miguel.dedios@artica.es> 2012-06-22 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/load_updatemanager.php, * extensions/update_manager/load_updatemanager.php,

View File

@ -161,10 +161,10 @@ echo "</tr><tr>";
echo "<td>".html_print_select ($agents, 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width:200px;')."</td>"; echo "<td>".html_print_select ($agents, 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width:200px;')."</td>";
} }
else {*/ else {*/
echo "<td>".html_print_select (agents_get_group_agents(), 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width:200px;')."</td>"; echo "<td>".html_print_select (agents_get_group_agents(), 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width:300px;')."</td>";
//} //}
echo "<td style='vertical-align: center; text-align: center;'>" . html_print_image("images/darrowright.png", true) . "</td>"; echo "<td style='vertical-align: center; text-align: center;'>" . html_print_image("images/darrowright.png", true) . "</td>";
echo "<td>".html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:200px;')."</td>"; echo "<td>".html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px;')."</td>";
echo "</tr><tr>"; echo "</tr><tr>";
echo "<td colspan='3'>"; echo "<td colspan='3'>";
echo "<table cellpadding='4'><tr>"; echo "<table cellpadding='4'><tr>";

View File

@ -4505,7 +4505,7 @@ function api_set_validate_events($id_event, $trash1, $other, $return_type, $user
} }
} }
function api_get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_db) { function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db) {
global $config; global $config;
//By default. //By default.
@ -4810,7 +4810,7 @@ function api_get_events__with_user($trash1, $trash2, $other, $returnType, $user_
*/ */
function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = null) { function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = null) {
if ($user_in_db !== null) { if ($user_in_db !== null) {
get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_db); get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db);
$last_error = error_get_last(); $last_error = error_get_last();
if (!empty($last_error)) { if (!empty($last_error)) {
$errors = array(E_ERROR, E_WARNING, E_USER_ERROR, $errors = array(E_ERROR, E_WARNING, E_USER_ERROR,

View File

@ -2318,14 +2318,22 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
case 'SLA': case 'SLA':
reporting_header_content($mini, $content, $report, $table, __('S.L.A.')); reporting_header_content($mini, $content, $report, $table, __('S.L.A.'));
$show_graph = $content['show_graph']; $edge_interval = 10;
// What show?
$show_table = $content['show_graph'] == 0 || $content['show_graph'] == 1;
$show_graphs = $content['show_graph'] == 1 || $content['show_graph'] == 2;
//RUNNING //RUNNING
$table->style[1] = 'text-align: right'; $table->style[1] = 'text-align: right';
// Put description at the end of the module (if exists) // Put description at the end of the module (if exists)
$table->colspan[1][0] = 3; $table->colspan[0][1] = 2;
$next_row = 1;
if ($content["description"] != ""){ if ($content["description"] != ""){
$table->colspan[$next_row][0] = 3;
$next_row++;
$data_desc = array(); $data_desc = array();
$data_desc[0] = $content["description"]; $data_desc[0] = $content["description"];
array_push ($table->data, $data_desc); array_push ($table->data, $data_desc);
@ -2333,15 +2341,17 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$slas = db_get_all_rows_field_filter ('treport_content_sla_combined', $slas = db_get_all_rows_field_filter ('treport_content_sla_combined',
'id_report_content', $content['id_rc']); 'id_report_content', $content['id_rc']);
if ($slas === false) { if ($slas === false) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[$next_row][0] = 3;
$next_row++;
$data[0] = __('There are no SLAs defined'); $data[0] = __('There are no SLAs defined');
array_push ($table->data, $data); array_push ($table->data, $data);
$slas = array (); $slas = array ();
break; break;
} }
elseif ($show_graph == 0 || $show_graph == 1) { elseif ($show_table) {
$table1->width = '99%'; $table1->width = '99%';
$table1->data = array (); $table1->data = array ();
$table1->head = array (); $table1->head = array ();
@ -2349,14 +2359,16 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table1->head[1] = __('Module'); $table1->head[1] = __('Module');
$table1->head[2] = __('Max/Min Values'); $table1->head[2] = __('Max/Min Values');
$table1->head[3] = __('SLA Limit'); $table1->head[3] = __('SLA Limit');
$table1->head[4] = __('Value'); $table1->head[4] = __('SLA Compliance');
$table1->head[5] = __('Status'); $table1->head[5] = __('Status');
$table1->head[6] = __('Criticity');
$table1->style[0] = 'text-align: left'; $table1->style[0] = 'text-align: left';
$table1->style[1] = 'text-align: left'; $table1->style[1] = 'text-align: left';
$table1->style[2] = 'text-align: right'; $table1->style[2] = 'text-align: right';
$table1->style[3] = 'text-align: right'; $table1->style[3] = 'text-align: right';
$table1->style[4] = 'text-align: right'; $table1->style[4] = 'text-align: right';
$table1->style[5] = 'text-align: right'; $table1->style[5] = 'text-align: right';
$table1->style[6] = 'text-align: center';
} }
$data_graph = array (); $data_graph = array ();
@ -2374,12 +2386,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$sla_failed = false; $sla_failed = false;
$total_SLA = 0; $total_SLA = 0;
$total_result_SLA = 'ok'; $total_result_SLA = 'ok';
$sla_showed = array();
$sla_showed_values = array();
foreach ($slas as $sla) { foreach ($slas as $sla) {
$server_name = $sla ['server_name']; $server_name = $sla ['server_name'];
//Metaconsole connection //Metaconsole connection
if (($config ['metaconsole'] == 1) && $server_name != '') { if (($config ['metaconsole'] == 1) && $server_name != '') {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) { if (!metaconsole_load_external_db($connection)) {
//ui_print_error_message ("Error connecting to ".$server_name); //ui_print_error_message ("Error connecting to ".$server_name);
continue; continue;
} }
@ -2389,7 +2404,43 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$sla_value = reporting_get_agentmodule_sla ($sla['id_agent_module'], $content['period'], $sla_value = reporting_get_agentmodule_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'], $sla['sla_min'], $sla['sla_max'], $report["datetime"], $content, $content['time_from'],
$content['time_to']); $content['time_to']);
//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 ()
if ($content['top_n'] == 2){
arsort($sla_showed_values);
}
// SLA items sorted ascending
else if ($content['top_n'] == 1){
asort($sla_showed_values);
}
// Slice graphs calculation
if ($show_graphs && !empty($slas)) {
$tableslice->width = '99%';
$tableslice->style[0] = 'text-align: right';
$tableslice->data = array ();
}
foreach ($sla_showed_values as $k => $sla_value) {
$sla = $sla_showed[$k];
$server_name = $sla ['server_name'];
//Metaconsole connection
if (($config ['metaconsole'] == 1) && $server_name != '') {
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue;
}
}
if ($sla_value === false) { if ($sla_value === false) {
if ($total_result_SLA != 'fail') if ($total_result_SLA != 'fail')
$total_result_SLA = 'unknown'; $total_result_SLA = 'unknown';
@ -2403,38 +2454,40 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data_graph[__('Unknown')]++; $data_graph[__('Unknown')]++;
$data_horin_graph[__('Unknown')]['g']++; $data_horin_graph[__('Unknown')]['g']++;
} }
else if ($sla_value <= ($sla['sla_limit']+10) && $sla_value >= ($sla['sla_limit']-10)) { else if ($sla_value <= ($sla['sla_limit']+$edge_interval) && $sla_value >= ($sla['sla_limit']-$edge_interval)) {
$data_graph[__('On the edge')]++; $data_graph[__('On the edge')]++;
$data_horin_graph[__('On the edge')]['g']++; $data_horin_graph[__('On the edge')]['g']++;
} }
else if ($sla_value > ($sla['sla_limit']+10)) { else if ($sla_value > ($sla['sla_limit']+$edge_interval)) {
$data_graph[__('Inside limits')]++; $data_graph[__('Inside limits')]++;
$data_horin_graph[__('Inside limits')]['g']++; $data_horin_graph[__('Inside limits')]['g']++;
} }
else if ($sla_value < ($sla['sla_limit']-10)) { else if ($sla_value < ($sla['sla_limit']-$edge_interval)) {
$data_graph[__('Out of limits')]++; $data_graph[__('Out of limits')]++;
$data_horin_graph[__('Out of limits')]['g']++; $data_horin_graph[__('Out of limits')]['g']++;
} }
//Do not show right modules if 'only_display_wrong' is active
if ($content['only_display_wrong'] == 1 && $sla_value >= $sla['sla_limit']) continue;
$total_SLA += $sla_value; $total_SLA += $sla_value;
if ($show_graph == 0 || $show_graph == 1) { if ($show_table) {
$data = array (); $data = array ();
$data[0] = modules_get_agentmodule_agent_name ($sla['id_agent_module']); $data[0] = modules_get_agentmodule_agent_name ($sla['id_agent_module']);
$data[1] = modules_get_agentmodule_name ($sla['id_agent_module']); $data[1] = modules_get_agentmodule_name ($sla['id_agent_module']);
$data[2] = $sla['sla_max'].'/'; $data[2] = $sla['sla_max'].'/';
$data[2] .= $sla['sla_min']; $data[2] .= $sla['sla_min'];
$data[3] = $sla['sla_limit']; $data[3] = $sla['sla_limit'].'%';
if ($sla_value === false) { if ($sla_value === false) {
$data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #0000FF;">'; $data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #0000FF;">';
$data[5] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #736F6E;">'.__('Unknown').'</span>'; $data[5] = html_print_image('images/status_sets/default/severity_maintenance.png',true,array('title'=>__('Unknown')));
$data[6] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #736F6E;">'.__('Unknown').'</span>';
} }
else { else {
if ($sla_value >= $sla['sla_limit']) { $data[4] = '';
$data[5] = '';
$data[6] = '';
if ($sla_value > $sla['sla_limit']) {
$data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'; $data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">';
$data[5] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.__('OK').'</span>'; $data[5] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.__('OK').'</span>';
} }
@ -2443,48 +2496,56 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'; $data[4] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">';
$data[5] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'.__('Fail').'</span>'; $data[5] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'.__('Fail').'</span>';
} }
// Print icon with status including edge
if ($sla_value > $sla['sla_limit']+$edge_interval) {
$data[6] = html_print_image('images/status_sets/default/severity_normal.png',true,array('title'=>__('Inside limits')));
}
elseif ($sla_value <= $sla['sla_limit']+$edge_interval && $sla_value >= $sla['sla_limit']-$edge_interval) {
$data[6] = html_print_image('images/status_sets/default/severity_warning.png',true,array('title'=>__('On the edge')));
}
else {
$data[6] = html_print_image('images/status_sets/default/severity_critical.png',true,array('title'=>__('Out of limits')));
}
$data[4] .= format_numeric ($sla_value, 2). "%"; $data[4] .= format_numeric ($sla_value, 2). "%";
} }
$data[4] .= "</span>"; $data[4] .= "</span>";
// This column will be used temporary for sort data
$data[6] = format_numeric ($sla_value, 2);
array_push ($table1->data, $data); array_push ($table1->data, $data);
} }
// Slice graphs calculation
if ($show_graphs) {
$dataslice = array();
$dataslice[0] = modules_get_agentmodule_agent_name ($sla['id_agent_module']);
$dataslice[0] .= "<br>";
$dataslice[0] .= modules_get_agentmodule_name ($sla['id_agent_module']);
$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,'');
array_push ($tableslice->data, $dataslice);
}
if ($config ['metaconsole'] == 1) { if ($config ['metaconsole'] == 1) {
//Restore db connection //Restore db connection
metaconsole_restore_db(); metaconsole_restore_db();
} }
} }
// SLA items sorted descending () if ($show_table) {
if ($content['top_n'] == 2){
usort($table1->data, "sla_value_desc_cmp");
}
// SLA items sorted ascending
else if ($content['top_n'] == 1){
usort($table1->data, "sla_value_asc_cmp");
}
// Delete temporary column used to sort SLA data
for ($i=0; $i < count($table1->data); $i++) {
unset($table1->data[$i][6]);
}
$next_row = 2;
if ($show_graph == 0 || $show_graph == 1) {
$data = array(); $data = array();
$data[0] = html_print_table($table1, true); $data[0] = html_print_table($table1, true);
array_push ($table->data, $data);
$table->colspan[$next_row][0] = 3; $table->colspan[$next_row][0] = 3;
$next_row++; $next_row++;
array_push ($table->data, $data);
} }
$table->colspan[$next_row][0] = 2;
$next_row++;
$data = array(); $data = array();
$data_pie_graph = json_encode ($data_graph); $data_pie_graph = json_encode ($data_graph);
if (($show_graph == 1 || $show_graph == 2) && !empty($slas)) { if ($show_graphs && !empty($slas)) {
$data[0] = pie3d_graph(false, $data_graph, $data[0] = pie3d_graph(false, $data_graph,
500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png", 500, 150, __("other"), "", $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']); $config['fontpath'], $config['font_size']);
@ -2492,46 +2553,34 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
//Print resume //Print resume
$table_resume = null; $table_resume = null;
$table_resume->head[0] = __('Resume Value'); $table_resume->head[0] = __('Average Value');
$table_resume->head[1] = __('Status');
if ($total_result_SLA == 'ok') { $table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">';
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'; $table_resume->data[0][0] .= format_numeric($total_SLA / count($sla_showed), 2);
$table_resume->data[0][1] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.__('OK').'</span>';
}
if ($total_result_SLA == 'fail') {
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">';
$table_resume->data[0][1] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'.__('Fail').'</span>';
}
if ($total_result_SLA == 'unknown') {
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #0000FF;">';
$table_resume->data[0][1] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #736F6E;">'.__('Unknown').'</span>';
}
$table_resume->data[0][0] .= format_numeric($total_SLA / count($slas), 2);
$table_resume->data[0][0] .= "%</span>"; $table_resume->data[0][0] .= "%</span>";
$data[1] = html_print_table($table_resume, true); $data[1] = html_print_table($table_resume, true);
$table_resume = null;
$table_resume->head[0] = __('SLA Compliance');
if ($total_result_SLA == 'ok') {
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.__('OK').'</span>';
}
if ($total_result_SLA == 'fail') {
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #ff0000;">'.__('Fail').'</span>';
}
if ($total_result_SLA == 'unknown') {
$table_resume->data[0][0] = '<span style="font: bold '.$sizem.'em Arial, Sans-serif; color: #736F6E;">'.__('Unknown').'</span>';
}
$data[2] = html_print_table($table_resume, true);
$next_row++;
array_push ($table->data, $data); array_push ($table->data, $data);
$table2->width = '99%';
$table2->style[0] = 'text-align: right';
$table2->data = array ();
foreach ($slas as $sla) {
$data = array();
$data[0] = modules_get_agentmodule_agent_name ($sla['id_agent_module']);
$data[0] .= "<br>";
$data[0] .= modules_get_agentmodule_name ($sla['id_agent_module']);
$data[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'], 550, 25,'');
array_push ($table2->data, $data);
}
$table->colspan[$next_row][0] = 3; $table->colspan[$next_row][0] = 3;
$next_row++;
$data = array(); $data = array();
$data[0] = html_print_table($table2, true); $data[0] = html_print_table($tableslice, true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
break; break;