feature change name interfaces

This commit is contained in:
daniel 2017-02-28 12:42:50 +01:00
parent 2109fcc875
commit 5a79f83bba
7 changed files with 71 additions and 69 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>
<?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();
$agents_select = array();
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");
?>
@ -1931,7 +1934,7 @@ $(document).ready (function () {
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["nombre"]);
.html (value["alias"]);
$("#id_agents").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)),
$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,31 +2386,36 @@ 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' OR nombre LIKE 'ifOperStatus_%')";
$modules = agents_get_modules($agent_id, $columns, $filter, true, false);
if (!empty($modules)) {
$interfaces = array();
$type_interface = 0;
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 ("/^(.+)_if.+/", $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)) {
$interfaces[$interface_name] = $module;
}
$interfaces[$interface_name] = $module;
$type_interface=0;
}
}
elseif( preg_match ("/^if.+_(.+)$/", $module_name, $matches) ){
if ($matches[1]) {
$interface_name = $matches[1];
$interface_name_escaped = str_replace("/", "\/", $interface_name);
$interfaces[$interface_name] = $module;
$type_interface=1;
}
}
}
unset($modules);
foreach ($interfaces as $interface_name => $module) {
$interface_name_escaped = str_replace("/", "\/", $interface_name);
@ -2447,19 +2451,36 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false)
"id_agente_modulo",
"nombre"
);
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE 'if%Octets_$interface_name'");
if($type_interface){
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE 'if%Octets_$interface_name'");
}else{
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE '" . $interface_name ."_if%Octets'");
}
if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) {
$interface_traffic_modules_aux = array('in' => '', 'out' => '');
foreach ($interface_traffic_modules as $interface_traffic_module) {
$interface_name_escaped = str_replace("/", "\/", $interface_name);
if (preg_match ("/^if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) {
if (strtolower($matches[1]) == 'in') {
$interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo'];
}
elseif (strtolower($matches[1]) == 'out') {
$interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo'];
if($type_interface){
if (preg_match ("/^if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) {
if (strtolower($matches[1]) == 'in') {
$interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo'];
}
elseif (strtolower($matches[1]) == 'out') {
$interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo'];
}
}
}
else {
if (preg_match ("/^" . $interface_name_escaped . "_if(.+)Octets$/i", $interface_traffic_module['nombre'], $matches)) {
if (strtolower($matches[1]) == 'in') {
$interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo'];
}
elseif (strtolower($matches[1]) == 'out') {
$interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo'];
}
}
}
}
if (!empty($interface_traffic_modules_aux['in']) && !empty($interface_traffic_modules_aux['out'])) {
$interface_traffic_modules = $interface_traffic_modules_aux;

View File

@ -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

View File

@ -80,31 +80,6 @@ function forecast_projection_graph($module_id,
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++;
}
$cont--;
@ -245,7 +220,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]) {

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']);
$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);

View File

@ -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->data['agents'][$id] = html_print_table($table_agent, true);
$table->colspan[$id][0] = 3;
$table->data[$id] = html_print_table($table_agent, true);
}
}
}
@ -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');

View File

@ -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 ---------------------------------------