From 8f8a17bf2439256a0fadbb28871961fd2e431ec5 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 27 Feb 2017 16:48:28 +0100 Subject: [PATCH] fixed alias for name in reports --- .../reporting_builder.item_editor.php | 9 ++- pandora_console/include/functions_agents.php | 21 ++++--- pandora_console/include/functions_events.php | 2 +- .../include/functions_forecast.php | 59 ++++++++++--------- .../include/functions_reporting.php | 25 ++++---- .../include/functions_reporting_html.php | 15 +++-- .../operation/reporting/reporting_viewer.php | 2 +- 7 files changed, 72 insertions(+), 61 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 57496a6ac8..9424f60979 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1078,12 +1078,15 @@ You can of course remove the warnings, that's why we include the source and do n @@ -1931,7 +1934,7 @@ $(document).ready (function () { option = $("") .attr ("value", value["id_agente"]) - .html (value["nombre"]); + .html (value["alias"]); $("#id_agents").append (option); $("#id_agents2").append (option); }); diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2f3c1d4073..55d4d9d1d1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1245,7 +1245,6 @@ function agents_get_modules ($id_agent = null, $details = false, io_safe_output(implode (",", (array) $details)), $where); - $result = db_get_all_rows_sql ($sql); @@ -2345,7 +2344,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) } $fields = array( 'id_agente', - 'nombre', + 'alias', 'id_grupo' ); $agents = agents_get_agents($filter, $fields); @@ -2356,7 +2355,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) foreach ($agents as $agent) { $agent_id = $agent['id_agente']; $agent_group_id = $agent['id_grupo']; - $agent_name = $agent['nombre']; + $agent_name = $agent['alias']; $agent_interfaces = array(); $accepted_module_types = array(); @@ -2387,23 +2386,28 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) else $columns[] = 'descripcion'; - $filter = " id_agente = $agent_id AND disabled = 0 AND id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND nombre LIKE 'ifOperStatus_%'"; + $filter = " id_agente = $agent_id AND disabled = 0 AND id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND nombre LIKE '%_ifOperStatus'"; $modules = agents_get_modules($agent_id, $columns, $filter, true, false); - + if (!empty($modules)) { + $interfaces = array(); foreach ($modules as $module) { $module_name = (string) $module['nombre']; // Trying to get the interface name from the module name - if (preg_match ("/_(.+)$/", $module_name, $matches)) { + + //if (preg_match ("/_(.+)$/", $module_name, $matches)) { + if (preg_match ("/^(.+)_/", $module_name, $matches)) { + if ($matches[1]) { $interface_name = $matches[1]; $interface_name_escaped = str_replace("/", "\/", $interface_name); - - if (preg_match ("/^ifOperStatus_$interface_name_escaped$/i", $module_name, $matches)) { + + //if (preg_match ("/^$interface_name_escaped_ifOperStatus$/i", $module_name, $matches)) { + if (preg_match ("/^".$interface_name_escaped."_ifOperStatus$/i", $module_name, $matches)) { $interfaces[$interface_name] = $module; } @@ -2411,7 +2415,6 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) } } unset($modules); - foreach ($interfaces as $interface_name => $module) { $interface_name_escaped = str_replace("/", "\/", $interface_name); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index e4f540393d..e001e00f90 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2687,7 +2687,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date, } $sql = sprintf ('SELECT id_agente, - (SELECT t2.nombre + (SELECT t2.alias FROM tagente t2 WHERE t2.id_agente = t3.id_agente) AS agent_name, COUNT(*) AS count diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 00e40693b2..ceafe817e2 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -76,35 +76,37 @@ function forecast_projection_graph($module_id, //$table->data = array(); // Creates data for calculation - foreach ($module_data as $utimestamp => $row) { - if ($utimestamp == '') { - continue; + if (is_array($module_data) || is_object($module_data)) { + foreach ($module_data as $utimestamp => $row) { + if ($utimestamp == '') { + continue; + } + + $data[0] = ''; + $data[1] = $cont; + $data[2] = date($config["date_format"], $utimestamp); + $data[3] = $utimestamp; + $data[4] = $row['sum']; + $data[5] = $utimestamp * $row['sum']; + $data[6] = $utimestamp * $utimestamp; + $data[7] = $row['sum'] * $row['sum']; + if ($cont == 1) { + $data[8] = 0; + } + else { + $data[8] = $utimestamp - $last_timestamp; + } + + $sum_obs = $sum_obs + $cont; + $sum_xi = $sum_xi + $utimestamp; + $sum_yi = $sum_yi + $row['sum']; + $sum_xi_yi = $sum_xi_yi + $data[5]; + $sum_xi2 = $sum_xi2 + $data[6]; + $sum_yi2 = $sum_yi2 + $data[7]; + $sum_diff_dates = $sum_diff_dates + $data[8]; + $last_timestamp = $utimestamp; + $cont++; } - - $data[0] = ''; - $data[1] = $cont; - $data[2] = date($config["date_format"], $utimestamp); - $data[3] = $utimestamp; - $data[4] = $row['sum']; - $data[5] = $utimestamp * $row['sum']; - $data[6] = $utimestamp * $utimestamp; - $data[7] = $row['sum'] * $row['sum']; - if ($cont == 1) { - $data[8] = 0; - } - else { - $data[8] = $utimestamp - $last_timestamp; - } - - $sum_obs = $sum_obs + $cont; - $sum_xi = $sum_xi + $utimestamp; - $sum_yi = $sum_yi + $row['sum']; - $sum_xi_yi = $sum_xi_yi + $data[5]; - $sum_xi2 = $sum_xi2 + $data[6]; - $sum_yi2 = $sum_yi2 + $data[7]; - $sum_diff_dates = $sum_diff_dates + $data[8]; - $last_timestamp = $utimestamp; - $cont++; } $cont--; @@ -245,7 +247,6 @@ function forecast_projection_graph($module_id, if ($current_ts - $last_timestamp >= 94608000) { return false; } - //html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]); // Found it if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 78bc4854c2..5d20944bfb 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1010,7 +1010,7 @@ function reporting_event_top_n($report, $content, $type = 'dinamic', } } - $ag_name = modules_get_agentmodule_agent_name($row ['id_agent_module']); + $ag_name = modules_get_agentmodule_agent_alias($row ['id_agent_module']); $mod_name = modules_get_agentmodule_name ($row ['id_agent_module']); $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $row ['id_agent_module']); @@ -1468,7 +1468,7 @@ function reporting_event_report_module($report, $content, } $return['title'] = $content['name']; - $return['subtitle'] = agents_get_name($content['id_agent']) . + $return['subtitle'] = agents_get_alias($content['id_agent']) . " - " . io_safe_output( modules_get_agentmodule_name($content['id_agent_module'])); @@ -1538,7 +1538,7 @@ function reporting_inventory_changes($report, $content, $type) { } $return['title'] = $content['name']; - $return['subtitle'] = agents_get_name($content['id_agent']); + $return['subtitle'] = agents_get_alias($content['id_agent']); $return["description"] = $content["description"]; $return["date"] = reporting_get_date_text($report, $content); @@ -2214,7 +2214,7 @@ function reporting_event_report_agent($report, $content, $history = true; $return['title'] = $content['name']; - $return['subtitle'] = agents_get_name($content['id_agent']); + $return['subtitle'] = agents_get_alias($content['id_agent']); $return["description"] = $content["description"]; $return["date"] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; @@ -2766,7 +2766,7 @@ function reporting_alert_report_group($report, $content) { $data_row = array(); - $data_row['agent'] = io_safe_output(agents_get_name( + $data_row['agent'] = io_safe_output(agents_get_alias( agents_get_agent_id_by_module_id($agent_module['id_agent_module']))); $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $agent_module['id_agent_module'])); @@ -2871,7 +2871,7 @@ function reporting_alert_report_agent($report, $content) { metaconsole_connect($server); } - $agent_name = agents_get_name($content['id_agent']); + $agent_name = agents_get_alias($content['id_agent']); $return['title'] = $content['name']; $return['subtitle'] = $agent_name; @@ -2992,7 +2992,7 @@ function reporting_alert_report_module($report, $content) { $module_name = io_safe_output( modules_get_agentmodule_name($content['id_agent_module'])); $agent_name = io_safe_output( - modules_get_agentmodule_agent_name ($content['id_agent_module'])); + modules_get_agentmodule_agent_alias ($content['id_agent_module'])); $return['title'] = $content['name']; $return['subtitle'] = $agent_name . " - " . $module_name; @@ -3004,7 +3004,7 @@ function reporting_alert_report_module($report, $content) { $data_row = array(); - $data_row['agent'] = io_safe_output(agents_get_name( + $data_row['agent'] = io_safe_output(agents_get_alias( agents_get_agent_id_by_module_id($content['id_agent_module']))); $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $content['id_agent_module'])); @@ -3013,7 +3013,7 @@ function reporting_alert_report_module($report, $content) { $alerts = alerts_get_effective_alert_actions($content['id_agent_module']); if ($alerts === false){ - continue; + return; } $ntemplates = 0; @@ -3538,7 +3538,7 @@ function reporting_agent_configuration($report, $content) { $agent_data = db_get_row_sql($sql); $agent_configuration = array(); - $agent_configuration['name'] = $agent_data['nombre']; + $agent_configuration['name'] = $agent_data['alias']; $agent_configuration['group'] = groups_get_name($agent_data['id_grupo']); $agent_configuration['group_icon'] = ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false); @@ -4929,7 +4929,7 @@ function reporting_availability($report, $content, $date=false, $time=false) { $item['id_agent_module']); } - $row['data']['agent'] = modules_get_agentmodule_agent_name( + $row['data']['agent'] = modules_get_agentmodule_agent_alias( $item['id_agent_module']); $text = $row['data']['agent'] . " (" . $text . ")"; @@ -5861,7 +5861,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic', $module_name = io_safe_output( modules_get_agentmodule_name($content['id_agent_module'])); $agent_name = io_safe_output( - modules_get_agentmodule_agent_name ($content['id_agent_module'])); + modules_get_agentmodule_agent_alias ($content['id_agent_module'])); @@ -10328,6 +10328,7 @@ function reporting_label_macro ($item, $label) { case 'event_report_agent': case 'alert_report_agent': case 'agent_configuration': + case 'event_report_log': if (preg_match("/_agent_/", $label)) { $agent_name = agents_get_alias($item['id_agent']); $label = str_replace("_agent_", $agent_name, $label); diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 4c23c2636f..98970b43f4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1463,6 +1463,7 @@ function reporting_html_exception($table, $item) { $table->data['group_report']['cell'] = $item['failed']; } else { + $table1 = new stdClass(); $table1->width = '99%'; $table1->align = array(); @@ -1805,6 +1806,7 @@ function reporting_html_event_report_agent($table, $item, $pdf = 0) { function reporting_html_historical_data($table, $item) { global $config; + $table1 = new stdClass(); $table1->width = '100%'; $table1->head = array (__('Date'), __('Data')); $table1->data = array (); @@ -1826,6 +1828,7 @@ function reporting_html_historical_data($table, $item) { function reporting_html_database_serialized($table, $item) { + $table1 = new stdClass(); $table1->width = '100%'; $table1->head = array (__('Date')); if (!empty($item['keys'])) { @@ -1882,7 +1885,7 @@ function reporting_html_network_interfaces_report($table, $item) { $table_agent->width = '100%'; $table_agent->data = array(); $table_agent->head = array(); - $table_agent->head[0] = sprintf(__("Agent '%s'"), $agent['name']); + $table_agent->head[0] = __("Agent") . " " . $agent['agent']; $table_agent->headstyle = array(); $table_agent->headstyle[0] = 'font-size: 16px;'; $table_agent->style[0] = 'text-align: center'; @@ -1901,8 +1904,8 @@ function reporting_html_network_interfaces_report($table, $item) { $table_interface->head['ip'] = __('IP'); $table_interface->head['mac'] = __('Mac'); $table_interface->head['status'] = __('Actual status'); - $table_interface->style['ip'] = 'text-align: left'; - $table_interface->style['mac'] = 'text-align: left'; + $table_interface->style['ip'] = 'text-align: center'; + $table_interface->style['mac'] = 'text-align: center'; $table_interface->style['status'] = 'width: 150px; text-align: center'; $data = array(); @@ -1922,9 +1925,9 @@ function reporting_html_network_interfaces_report($table, $item) { } $id = uniqid(); - + $table->colspan['agents'][$id] = 3; $table->data['agents'][$id] = html_print_table($table_agent, true); - $table->colspan[$id][0] = 3; + } } } @@ -2437,7 +2440,7 @@ function reporting_html_availability(&$table, $item) { $table1->width = '99%'; $table1->data = array (); - if (($same_agent_in_resume == "") && (strpos($item['resume']['min_text'], $same_agent_in_resume) === false)) { + if (! empty($same_agent_in_resume) && ($same_agent_in_resume == "") && (strpos($item['resume']['min_text'], $same_agent_in_resume) === false)) { $table1->head = array (); $table1->head['max_text'] = __('Agent max value'); $table1->head['max'] = __('Max Value'); diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 63926b03c5..be89ac1149 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -125,7 +125,7 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) { } else { ui_print_page_header (reporting_get_name($id_report), "images/op_reporting.png", - false, "", false, $options,false,'',50); + false, "", false, $options,false,'',55); } //------------------- END HEADER ---------------------------------------