2012-04-30 Miguel de Dios <miguel.dedios@artica.es>

* godmode/reporting/visual_console_builder.php: fixed when the
	module have a spaces or other entities in the name when try to
	create a items with the wizzard.
	
	* godmode/reporting/visual_console_builder.wizard.php: changed the
	style of form to show more horizontality.
	
	Fixes: #3521724
	
	
	
	* include/functions_reporting.php: fixed the "Top-N".
	
	Fixes: #3521724
	
	* include/functions_agents.php: cleaned source code style.
	
	* operation/agentes/ver_agente.php: return more data in the ajax
	request for the modules.
	
	MERGED FROM 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-04-30 12:44:26 +00:00
parent 616a926d21
commit ffad6bb505
6 changed files with 93 additions and 74 deletions

View File

@ -1,3 +1,27 @@
2012-04-30 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/visual_console_builder.php: fixed when the
module have a spaces or other entities in the name when try to
create a items with the wizzard.
* godmode/reporting/visual_console_builder.wizard.php: changed the
style of form to show more horizontality.
Fixes: #3521724
* include/functions_reporting.php: fixed the "Top-N".
Fixes: #3521724
* include/functions_agents.php: cleaned source code style.
* operation/agentes/ver_agente.php: return more data in the ajax
request for the modules.
MERGED FROM 4.0.2
2012-04-30 Vanessa Gil <vanessa.gil@artica.es> 2012-04-30 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.php * pandoradb.php

View File

@ -208,13 +208,15 @@ switch ($activeTab) {
} }
else { else {
$id_modules = array(); $id_modules = array();
foreach($name_modules as $mod){ foreach ($name_modules as $mod) {
foreach($id_agents as $ag){ foreach ($id_agents as $ag) {
$sql = "SELECT id_agente_modulo $id_module = agents_get_modules($ag,
FROM tagente_modulo array('id_agente_modulo'),
WHERE delete_pending = 0 AND id_agente = ".$ag." AND nombre = '".$mod."'"; array('nombre' => io_safe_input($mod)));
$result = db_get_row_sql ($sql); if (empty($id_module))
$id_modules[] = $result['id_agente_modulo']; continue;
$id_modules[] = $id_module;
} }
} }
$message .= visual_map_process_wizard_add_modules($id_modules, $message .= visual_map_process_wizard_add_modules($id_modules,

View File

@ -32,8 +32,8 @@ $table->id = 'wizard_table';
$table->width = '98%'; $table->width = '98%';
$table->data = array (); $table->data = array ();
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top'; $table->style[0] = 'font-weight: bold; vertical-align: text-top;';
$table->style[2] = 'font-weight: bold'; $table->style[1] = 'font-weight: bold; vertical-align: top;';
$table->size = array (); $table->size = array ();
$table->data = array (); $table->data = array ();
@ -72,7 +72,7 @@ $table->data["all_1"][1] = html_print_input_text ('range', 50, '', 5, 5, true);
$table->rowstyle["staticgraph_modulegraph"] = 'display: none;'; $table->rowstyle["staticgraph_modulegraph"] = 'display: none;';
$table->data["staticgraph_modulegraph"][0] = __('Size (px)'); $table->data["staticgraph_modulegraph"][0] = __('Size (px)');
$table->data["staticgraph_modulegraph"][1] = __('Width').': '.html_print_input_text ('width', 0, '', 5, 5, true); $table->data["staticgraph_modulegraph"][1] = __('Width').': '.html_print_input_text ('width', 0, '', 5, 5, true);
$table->data["staticgraph_modulegraph"][1] .= '<br />'.__('Height').': '.html_print_input_text ('height', 0, '', 5, 5, true); $table->data["staticgraph_modulegraph"][1] .= ' ' . __('Height').': '.html_print_input_text ('height', 0, '', 5, 5, true);
$table->rowstyle["modulegraph"] = 'display: none;'; $table->rowstyle["modulegraph"] = 'display: none;';
$table->data["modulegraph"][0] = __('Period'); $table->data["modulegraph"][0] = __('Period');
@ -111,11 +111,9 @@ $table->data["all_2"][1] = html_print_select_groups($config['id_user'], "AR", tr
$table->rowstyle["all_3"] = 'display: none;'; $table->rowstyle["all_3"] = 'display: none;';
$table->data["all_3"][0] = __('Agents'); $table->data["all_3"][0] = __('Agents');
$table->data["all_3"][1] = html_print_select (agents_get_group_agents (0, false, "none", false, true), $table->data["all_3"][1] = html_print_select (agents_get_group_agents (0, false, "none", false, true),
'id_agents[]', 0, false, '', '', true, true); 'id_agents[]', 0, false, '', '', true, true) .
' <span style="vertical-align: top;">' . __('Modules') . '</span>' .
$table->rowstyle["all_4"] = 'display: none;'; html_print_select (array (), 'module[]', 0, false, __('None'), -1, true, true);
$table->data["all_4"][0] = __('Modules');
$table->data["all_4"][1] = html_print_select (array (), 'module[]', 0, false, __('None'), -1, true, true);
$table->rowstyle["all_5"] = 'display: none;'; $table->rowstyle["all_5"] = 'display: none;';
$table->data["all_5"][0] = __('Label'); $table->data["all_5"][0] = __('Label');

View File

@ -1075,7 +1075,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false
if($id_agent == false) { if($id_agent == false) {
$id_agent = array(); $id_agent = array();
} }
$temp = array(); $temp = array();
foreach ($id_agent as $item) { foreach ($id_agent as $item) {
$temp[] = $item['id_agente']; $temp[] = $item['id_agente'];

View File

@ -2312,8 +2312,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
// Important parameter, this tell to graphic_combined_module function that is a projection graph // Important parameter, this tell to graphic_combined_module function that is a projection graph
$output_projection, $output_projection,
$content['top_n_value'] $content['top_n_value']
); );
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;
case 'prediction_date': case 'prediction_date':
reporting_header_content($mini, $content, $report, $table, __('Prediction date'), reporting_header_content($mini, $content, $report, $table, __('Prediction date'),
@ -2322,7 +2322,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
//RUNNING //RUNNING
$table->colspan[1][0] = 4; $table->colspan[1][0] = 4;
set_time_limit(500); set_time_limit(500);
// Put description at the end of the module (if exists) // Put description at the end of the module (if exists)
$table->colspan[2][0] = 4; $table->colspan[2][0] = 4;
@ -2585,20 +2585,20 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
metaconsole_restore_db(); metaconsole_restore_db();
} }
} }
// SLA items sorted descending () // SLA items sorted descending ()
if ($content['top_n'] == 2){ if ($content['top_n'] == 2){
usort($table1->data, "sla_value_desc_cmp"); usort($table1->data, "sla_value_desc_cmp");
} }
// SLA items sorted ascending // SLA items sorted ascending
else if ($content['top_n'] == 1){ else if ($content['top_n'] == 1){
usort($table1->data, "sla_value_asc_cmp"); usort($table1->data, "sla_value_asc_cmp");
} }
// Delete temporary column used to sort SLA data // Delete temporary column used to sort SLA data
for ($i=0; $i < count($table1->data); $i++) { for ($i=0; $i < count($table1->data); $i++) {
unset($table1->data[$i][6]); unset($table1->data[$i][6]);
} }
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
if ($show_graph == 0 || $show_graph == 1) { if ($show_graph == 0 || $show_graph == 1) {
@ -2606,14 +2606,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[0] = html_print_table($table1, true); $data[0] = html_print_table($table1, true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
$table->colspan[3][0] = 2; $table->colspan[3][0] = 2;
$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_graph == 1 || $show_graph == 2) && !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']);
//Print resume //Print resume
@ -3401,7 +3402,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
else { else {
$data[3] = format_for_graph($d, 2) . " " . $units[$i]; $data[3] = format_for_graph($d, 2) . " " . $units[$i];
} }
array_push ($table1->data, $data); array_push ($table1->data, $data);
$i++; $i++;
} }
@ -3458,6 +3458,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
continue; continue;
} }
} }
$ag_name = modules_get_agentmodule_agent_name ($general ['id_agent_module']); $ag_name = modules_get_agentmodule_agent_name ($general ['id_agent_module']);
if (!in_array ($ag_name, $agent_list)) { if (!in_array ($ag_name, $agent_list)) {
array_push ($agent_list, $ag_name); array_push ($agent_list, $ag_name);
@ -3503,6 +3504,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
continue; continue;
} }
} }
$agent_name = modules_get_agentmodule_agent_name ($g['id_agent_module']); $agent_name = modules_get_agentmodule_agent_name ($g['id_agent_module']);
$module_name = modules_get_agentmodule_name ($g['id_agent_module']); $module_name = modules_get_agentmodule_name ($g['id_agent_module']);
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $g['id_agent_module']); $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $g['id_agent_module']);
@ -3712,6 +3714,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table1->style[2] = 'text-align: left'; $table1->style[2] = 'text-align: left';
} }
//Get data of all agents (before to slide to N values)
$data_top = array(); $data_top = array();
foreach ($tops as $key => $row) { foreach ($tops as $key => $row) {
@ -3760,42 +3763,16 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
metaconsole_restore_db(); metaconsole_restore_db();
} }
} }
if(empty($data_top)) {
if (empty($data_top)) {
$data = array (); $data = array ();
$table->colspan[2][0] = 3; $table->colspan[2][0] = 3;
$data[0] = __('Insuficient data'); $data[0] = __('Insuficient data');
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;
} }
switch ($top_n) {
//Max
case 1:
array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC);
break;
//Min
case 2:
array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC);
break;
//By agent name or without selection
case 0:
case 3:
array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC);
break;
}
$data_top_values = array ();
$data_top_values['data_top'] = $data_top;
$data_top_values['agent_name'] = $agent_name;
$data_top_values['module_name'] = $module_name;
$data_top_values['id_agent_module'] = $id_agent_module;
$data_top_values['units'] = $units;
array_splice ($data_top, $top_n_value);
array_splice ($agent_name, $top_n_value);
array_splice ($module_name, $top_n_value);
array_splice ($id_agent_module, $top_n_value);
array_splice ($units, $top_n_value);
//Order to show.
switch ($order_uptodown) { switch ($order_uptodown) {
//Descending //Descending
case 1: case 1:
@ -3812,6 +3789,19 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
break; break;
} }
array_splice ($data_top, $top_n_value);
array_splice ($agent_name, $top_n_value);
array_splice ($module_name, $top_n_value);
array_splice ($id_agent_module, $top_n_value);
array_splice ($units, $top_n_value);
$data_top_values = array ();
$data_top_values['data_top'] = $data_top;
$data_top_values['agent_name'] = $agent_name;
$data_top_values['module_name'] = $module_name;
$data_top_values['id_agent_module'] = $id_agent_module;
$data_top_values['units'] = $units;
// Define truncate size depends the graph width // Define truncate size depends the graph width
$truncate_size = $sizgraph_w / (4 * ($config['font_size']))-1; $truncate_size = $sizgraph_w / (4 * ($config['font_size']))-1;
@ -3874,7 +3864,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[0] = html_print_table($table1, true); $data[0] = html_print_table($table1, true);
array_push ($table->data, $data); array_push ($table->data, $data);
} }
$table->colspan[3][0] = 3; $table->colspan[3][0] = 3;
$data = array(); $data = array();
if ($show_graph == 1 || $show_graph == 2) { if ($show_graph == 1 || $show_graph == 2) {
@ -3925,7 +3915,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table_summary->data[0][0] = format_for_graph($min, 2); $table_summary->data[0][0] = format_for_graph($min, 2);
$table_summary->data[0][1] = format_for_graph($avg, 2); $table_summary->data[0][1] = format_for_graph($avg, 2);
$table_summary->data[0][2] = format_for_graph($max, 2); $table_summary->data[0][2] = format_for_graph($max, 2);
$table->colspan[5][0] = 3; $table->colspan[5][0] = 3;
array_push ($table->data, array('<b>'.__('Summary').'</b>')); array_push ($table->data, array('<b>'.__('Summary').'</b>'));
$table->colspan[6][0] = 3; $table->colspan[6][0] = 3;

View File

@ -42,11 +42,11 @@ if (is_ajax ()) {
$get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip"); $get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip");
$get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip"); $get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip");
$get_agent_id = (bool) get_parameter ("get_agent_id"); $get_agent_id = (bool) get_parameter ("get_agent_id");
if ($get_agents_group_json) { if ($get_agents_group_json) {
$id_group = (int) get_parameter('id_group'); $id_group = (int) get_parameter('id_group');
$recursion = (int) get_parameter ('recursion', 0); $recursion = (int) get_parameter ('recursion', 0);
if($id_group > 0) { if($id_group > 0) {
$groups = array($id_group); $groups = array($id_group);
if ($recursion) { if ($recursion) {
@ -55,17 +55,17 @@ if (is_ajax ()) {
} }
else { else {
$groups_orig = users_get_groups(); $groups_orig = users_get_groups();
$groups = array_keys($groups_orig); $groups = array_keys($groups_orig);
} }
$filter = " WHERE id_grupo IN (". implode(',', $groups) .")"; $filter = " WHERE id_grupo IN (". implode(',', $groups) .")";
$agents = db_get_all_rows_sql("SELECT id_agente, nombre FROM tagente". $filter); $agents = db_get_all_rows_sql("SELECT id_agente, nombre FROM tagente". $filter);
echo json_encode($agents); echo json_encode($agents);
return; return;
} }
if ($get_agent_json) { if ($get_agent_json) {
$id_agent = (int) get_parameter ('id_agent'); $id_agent = (int) get_parameter ('id_agent');
@ -78,10 +78,15 @@ if (is_ajax ()) {
if ($get_agent_modules_json_for_multiple_agents_id) { if ($get_agent_modules_json_for_multiple_agents_id) {
$idAgents = get_parameter('id_agent'); $idAgents = get_parameter('id_agent');
$nameModules = db_get_all_rows_sql('SELECT nombre, id_agente_modulo $modules = db_get_all_rows_sql('SELECT nombre, id_agente_modulo
FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')'); FROM tagente_modulo WHERE id_agente IN (' . implode(',', $idAgents) . ')');
echo json_encode($nameModules); $return = array();
foreach ($modules as $module) {
$return[$module['id_agente_modulo']] = $module['nombre'];
}
echo json_encode($return);
return; return;
} }
@ -93,7 +98,7 @@ if (is_ajax ()) {
FROM tagente t1, tagente_modulo t2 FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente WHERE t1.id_agente = t2.id_agente
AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')'; AND t2.nombre IN (\'' . implode('\',\'', $nameModules) . '\')';
if($selection_mode == 'common') { if($selection_mode == 'common') {
$sql .= 'AND ( $sql .= 'AND (
SELECT count(t3.nombre) SELECT count(t3.nombre)
@ -103,10 +108,10 @@ if (is_ajax ()) {
} }
$sql .= ' ORDER BY t1.nombre'; $sql .= ' ORDER BY t1.nombre';
$nameAgents = db_get_all_rows_sql($sql); $nameAgents = db_get_all_rows_sql($sql);
foreach($nameAgents as $nameAgent) { foreach ($nameAgents as $nameAgent) {
$names[] = $nameAgent['name']; $names[] = $nameAgent['name'];
} }
@ -169,13 +174,13 @@ if (is_ajax ()) {
$enabled = 'disabled = 0'; $enabled = 'disabled = 0';
break; break;
} }
if ($config ['metaconsole'] == 1) { if ($config ['metaconsole'] == 1) {
$result = array(); $result = array();
$nameModules = array(); $nameModules = array();
$temp = array(); $temp = array();
$first = true; $first = true;
foreach ($idAgents as $idA) { foreach ($idAgents as $idA) {
$row = explode ('|', $idA); $row = explode ('|', $idA);
$server_name = $row[0]; $server_name = $row[0];
@ -230,13 +235,13 @@ if (is_ajax ()) {
} }
$sql .= ' ORDER BY nombre'; $sql .= ' ORDER BY nombre';
$nameModules = db_get_all_rows_sql($sql); $nameModules = db_get_all_rows_sql($sql);
if ($nameModules == false) { if ($nameModules == false) {
$nameModules = array(); $nameModules = array();
} }
$result = array(); $result = array();
foreach($nameModules as $nameModule) { foreach($nameModules as $nameModule) {
$result[] = io_safe_output($nameModule['nombre']); $result[] = io_safe_output($nameModule['nombre']);
@ -246,7 +251,7 @@ if (is_ajax ()) {
echo json_encode($result); echo json_encode($result);
return; return;
} }
if ($get_agent_modules_json) { if ($get_agent_modules_json) {
$id_agent = (int) get_parameter ('id_agent'); $id_agent = (int) get_parameter ('id_agent');
$filter = io_safe_output((string) get_parameter ('filter')); $filter = io_safe_output((string) get_parameter ('filter'));