fixed alias for name in reports

This commit is contained in:
daniel 2017-02-27 16:48:28 +01:00
parent 2109fcc875
commit 8f8a17bf24
7 changed files with 72 additions and 61 deletions

View File

@ -1078,12 +1078,15 @@ You can of course remove the warnings, that's why we include the source and do n
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td> <td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
<td> <td>
<?php <?php
$agents = enterprise_hook('inventory_get_agents'); $fields = array ();
$fields[0] = "id_agente";
$fields[1] = "alias";
$agents = enterprise_hook('inventory_get_agents', array(false , $fields));
if ((empty($agents)) || $agents == -1) $agents = array(); if ((empty($agents)) || $agents == -1) $agents = array();
$agents_select = array(); $agents_select = array();
foreach ($agents as $a) { foreach ($agents as $a) {
$agents_select[$a['id_agente']] = $a['nombre']; $agents_select[$a['id_agente']] = $a['alias'];
} }
html_print_select($agents_select, 'id_agents[]', $id_agents, $script = '', __('All'), -1, false, true, true, '', false, "min-width: 180px"); html_print_select($agents_select, 'id_agents[]', $id_agents, $script = '', __('All'), -1, false, true, true, '', false, "min-width: 180px");
?> ?>
@ -1931,7 +1934,7 @@ $(document).ready (function () {
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["nombre"]); .html (value["alias"]);
$("#id_agents").append (option); $("#id_agents").append (option);
$("#id_agents2").append (option); $("#id_agents2").append (option);
}); });

View File

@ -1245,7 +1245,6 @@ function agents_get_modules ($id_agent = null, $details = false,
io_safe_output(implode (",", (array) $details)), io_safe_output(implode (",", (array) $details)),
$where); $where);
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
@ -2345,7 +2344,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
} }
$fields = array( $fields = array(
'id_agente', 'id_agente',
'nombre', 'alias',
'id_grupo' 'id_grupo'
); );
$agents = agents_get_agents($filter, $fields); $agents = agents_get_agents($filter, $fields);
@ -2356,7 +2355,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
foreach ($agents as $agent) { foreach ($agents as $agent) {
$agent_id = $agent['id_agente']; $agent_id = $agent['id_agente'];
$agent_group_id = $agent['id_grupo']; $agent_group_id = $agent['id_grupo'];
$agent_name = $agent['nombre']; $agent_name = $agent['alias'];
$agent_interfaces = array(); $agent_interfaces = array();
$accepted_module_types = array(); $accepted_module_types = array();
@ -2387,23 +2386,28 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
else else
$columns[] = 'descripcion'; $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); $modules = agents_get_modules($agent_id, $columns, $filter, true, false);
if (!empty($modules)) { if (!empty($modules)) {
$interfaces = array(); $interfaces = array();
foreach ($modules as $module) { foreach ($modules as $module) {
$module_name = (string) $module['nombre']; $module_name = (string) $module['nombre'];
// Trying to get the interface name from the module name // 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]) { if ($matches[1]) {
$interface_name = $matches[1]; $interface_name = $matches[1];
$interface_name_escaped = str_replace("/", "\/", $interface_name); $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; $interfaces[$interface_name] = $module;
} }
@ -2411,7 +2415,6 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
} }
} }
unset($modules); unset($modules);
foreach ($interfaces as $interface_name => $module) { foreach ($interfaces as $interface_name => $module) {
$interface_name_escaped = str_replace("/", "\/", $interface_name); $interface_name_escaped = str_replace("/", "\/", $interface_name);

View File

@ -2687,7 +2687,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
} }
$sql = sprintf ('SELECT id_agente, $sql = sprintf ('SELECT id_agente,
(SELECT t2.nombre (SELECT t2.alias
FROM tagente t2 FROM tagente t2
WHERE t2.id_agente = t3.id_agente) AS agent_name, WHERE t2.id_agente = t3.id_agente) AS agent_name,
COUNT(*) AS count COUNT(*) AS count

View File

@ -76,6 +76,7 @@ function forecast_projection_graph($module_id,
//$table->data = array(); //$table->data = array();
// Creates data for calculation // Creates data for calculation
if (is_array($module_data) || is_object($module_data)) {
foreach ($module_data as $utimestamp => $row) { foreach ($module_data as $utimestamp => $row) {
if ($utimestamp == '') { if ($utimestamp == '') {
continue; continue;
@ -106,6 +107,7 @@ function forecast_projection_graph($module_id,
$last_timestamp = $utimestamp; $last_timestamp = $utimestamp;
$cont++; $cont++;
} }
}
$cont--; $cont--;
@ -245,7 +247,6 @@ function forecast_projection_graph($module_id,
if ($current_ts - $last_timestamp >= 94608000) { if ($current_ts - $last_timestamp >= 94608000) {
return false; return false;
} }
//html_debug_print(" Date " . $timestamp_f . " data: " . $output_data[$timestamp_f]);
// Found it // Found it
if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]) { if ($max_value >= $output_data[$timestamp_f] and $min_value <= $output_data[$timestamp_f]) {

View File

@ -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']); $mod_name = modules_get_agentmodule_name ($row ['id_agent_module']);
$unit = db_get_value('unit', 'tagente_modulo', $unit = db_get_value('unit', 'tagente_modulo',
'id_agente_modulo', $row ['id_agent_module']); 'id_agente_modulo', $row ['id_agent_module']);
@ -1468,7 +1468,7 @@ function reporting_event_report_module($report, $content,
} }
$return['title'] = $content['name']; $return['title'] = $content['name'];
$return['subtitle'] = agents_get_name($content['id_agent']) . $return['subtitle'] = agents_get_alias($content['id_agent']) .
" - " . " - " .
io_safe_output( io_safe_output(
modules_get_agentmodule_name($content['id_agent_module'])); modules_get_agentmodule_name($content['id_agent_module']));
@ -1538,7 +1538,7 @@ function reporting_inventory_changes($report, $content, $type) {
} }
$return['title'] = $content['name']; $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["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
@ -2214,7 +2214,7 @@ function reporting_event_report_agent($report, $content,
$history = true; $history = true;
$return['title'] = $content['name']; $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["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $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 = 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']))); agents_get_agent_id_by_module_id($agent_module['id_agent_module'])));
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo', $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
array('id_agente_modulo' => $agent_module['id_agent_module'])); array('id_agente_modulo' => $agent_module['id_agent_module']));
@ -2871,7 +2871,7 @@ function reporting_alert_report_agent($report, $content) {
metaconsole_connect($server); metaconsole_connect($server);
} }
$agent_name = agents_get_name($content['id_agent']); $agent_name = agents_get_alias($content['id_agent']);
$return['title'] = $content['name']; $return['title'] = $content['name'];
$return['subtitle'] = $agent_name; $return['subtitle'] = $agent_name;
@ -2992,7 +2992,7 @@ function reporting_alert_report_module($report, $content) {
$module_name = io_safe_output( $module_name = io_safe_output(
modules_get_agentmodule_name($content['id_agent_module'])); modules_get_agentmodule_name($content['id_agent_module']));
$agent_name = io_safe_output( $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['title'] = $content['name'];
$return['subtitle'] = $agent_name . " - " . $module_name; $return['subtitle'] = $agent_name . " - " . $module_name;
@ -3004,7 +3004,7 @@ function reporting_alert_report_module($report, $content) {
$data_row = array(); $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']))); agents_get_agent_id_by_module_id($content['id_agent_module'])));
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo', $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
array('id_agente_modulo' => $content['id_agent_module'])); 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']); $alerts = alerts_get_effective_alert_actions($content['id_agent_module']);
if ($alerts === false){ if ($alerts === false){
continue; return;
} }
$ntemplates = 0; $ntemplates = 0;
@ -3538,7 +3538,7 @@ function reporting_agent_configuration($report, $content) {
$agent_data = db_get_row_sql($sql); $agent_data = db_get_row_sql($sql);
$agent_configuration = array(); $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'] = groups_get_name($agent_data['id_grupo']);
$agent_configuration['group_icon'] = $agent_configuration['group_icon'] =
ui_print_group_icon ($agent_data['id_grupo'], true, '', '', false); 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']); $item['id_agent_module']);
} }
$row['data']['agent'] = modules_get_agentmodule_agent_name( $row['data']['agent'] = modules_get_agentmodule_agent_alias(
$item['id_agent_module']); $item['id_agent_module']);
$text = $row['data']['agent'] . " (" . $text . ")"; $text = $row['data']['agent'] . " (" . $text . ")";
@ -5861,7 +5861,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
$module_name = io_safe_output( $module_name = io_safe_output(
modules_get_agentmodule_name($content['id_agent_module'])); modules_get_agentmodule_name($content['id_agent_module']));
$agent_name = io_safe_output( $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 'event_report_agent':
case 'alert_report_agent': case 'alert_report_agent':
case 'agent_configuration': case 'agent_configuration':
case 'event_report_log':
if (preg_match("/_agent_/", $label)) { if (preg_match("/_agent_/", $label)) {
$agent_name = agents_get_alias($item['id_agent']); $agent_name = agents_get_alias($item['id_agent']);
$label = str_replace("_agent_", $agent_name, $label); $label = str_replace("_agent_", $agent_name, $label);

View File

@ -1463,6 +1463,7 @@ function reporting_html_exception($table, $item) {
$table->data['group_report']['cell'] = $item['failed']; $table->data['group_report']['cell'] = $item['failed'];
} }
else { else {
$table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
$table1->align = array(); $table1->align = array();
@ -1805,6 +1806,7 @@ function reporting_html_event_report_agent($table, $item, $pdf = 0) {
function reporting_html_historical_data($table, $item) { function reporting_html_historical_data($table, $item) {
global $config; global $config;
$table1 = new stdClass();
$table1->width = '100%'; $table1->width = '100%';
$table1->head = array (__('Date'), __('Data')); $table1->head = array (__('Date'), __('Data'));
$table1->data = array (); $table1->data = array ();
@ -1826,6 +1828,7 @@ function reporting_html_historical_data($table, $item) {
function reporting_html_database_serialized($table, $item) { function reporting_html_database_serialized($table, $item) {
$table1 = new stdClass();
$table1->width = '100%'; $table1->width = '100%';
$table1->head = array (__('Date')); $table1->head = array (__('Date'));
if (!empty($item['keys'])) { if (!empty($item['keys'])) {
@ -1882,7 +1885,7 @@ function reporting_html_network_interfaces_report($table, $item) {
$table_agent->width = '100%'; $table_agent->width = '100%';
$table_agent->data = array(); $table_agent->data = array();
$table_agent->head = 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 = array();
$table_agent->headstyle[0] = 'font-size: 16px;'; $table_agent->headstyle[0] = 'font-size: 16px;';
$table_agent->style[0] = 'text-align: center'; $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['ip'] = __('IP');
$table_interface->head['mac'] = __('Mac'); $table_interface->head['mac'] = __('Mac');
$table_interface->head['status'] = __('Actual status'); $table_interface->head['status'] = __('Actual status');
$table_interface->style['ip'] = 'text-align: left'; $table_interface->style['ip'] = 'text-align: center';
$table_interface->style['mac'] = 'text-align: left'; $table_interface->style['mac'] = 'text-align: center';
$table_interface->style['status'] = 'width: 150px; text-align: center'; $table_interface->style['status'] = 'width: 150px; text-align: center';
$data = array(); $data = array();
@ -1922,9 +1925,9 @@ function reporting_html_network_interfaces_report($table, $item) {
} }
$id = uniqid(); $id = uniqid();
$table->colspan['agents'][$id] = 3;
$table->data['agents'][$id] = html_print_table($table_agent, true); $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->width = '99%';
$table1->data = array (); $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 = array ();
$table1->head['max_text'] = __('Agent max value'); $table1->head['max_text'] = __('Agent max value');
$table1->head['max'] = __('Max Value'); $table1->head['max'] = __('Max Value');

View File

@ -125,7 +125,7 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
} }
else { else {
ui_print_page_header (reporting_get_name($id_report), "images/op_reporting.png", 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 --------------------------------------- //------------------- END HEADER ---------------------------------------