fixed missing name and current value in snmp interface wizard when using satellite

This commit is contained in:
alejandro.campos@artica.es 2021-11-11 15:25:44 +01:00
parent 6b724b7747
commit 49d9271b4e

View File

@ -441,10 +441,8 @@ class AgentWizard extends HTML
$this->resultsInterfaceWizard(); $this->resultsInterfaceWizard();
} }
} else { } else {
hd('obtiene module blocks1', true);
$this->moduleBlocks = $this->getModuleBlocks(); $this->moduleBlocks = $this->getModuleBlocks();
hd($this->moduleBlocks, true);
// TRAZA0: hd($this->moduleBlocks, true); /// PARA VER CUÁL ES EL ID QUE TENEMOS QUE BUSCAR EN tnetwork_component.
if ($this->moduleBlocks === false) { if ($this->moduleBlocks === false) {
$this->message['type'][] = 'info'; $this->message['type'][] = 'info';
$this->message['message'][] = __( $this->message['message'][] = __(
@ -949,12 +947,10 @@ class AgentWizard extends HTML
// Set the name of interface. // Set the name of interface.
$interfaces[$indexKey]['name'] = $name; $interfaces[$indexKey]['name'] = $name;
// Get the description. // Get the description.
hd('AQUI0', true);
$interfaces[$indexKey]['descr'] = $this->snmpGetValue( $interfaces[$indexKey]['descr'] = $this->snmpGetValue(
'.1.3.6.1.2.1.2.2.1.2.'.$indexKey '.1.3.6.1.2.1.2.2.1.2.'.$indexKey
); );
// Get the MAC address. // Get the MAC address.
hd('AQUI1', true);
$interfaces[$indexKey]['mac'] = $this->snmpGetValue( $interfaces[$indexKey]['mac'] = $this->snmpGetValue(
'.1.3.6.1.2.1.2.2.1.6.'.$indexKey '.1.3.6.1.2.1.2.2.1.6.'.$indexKey
); );
@ -965,13 +961,11 @@ class AgentWizard extends HTML
} }
// Get interface alias. // Get interface alias.
hd('AQUI2', true);
$interfaces[$indexKey]['alias'] = $this->snmpGetValue( $interfaces[$indexKey]['alias'] = $this->snmpGetValue(
'.1.3.6.1.2.1.31.1.1.1.18.'.$indexKey '.1.3.6.1.2.1.31.1.1.1.18.'.$indexKey
); );
// Get interface speed. // Get interface speed.
hd('AQUI3', true);
$interfaces[$indexKey]['speed'] = $this->snmpGetValue( $interfaces[$indexKey]['speed'] = $this->snmpGetValue(
'.1.3.6.1.2.1.2.2.1.5.'.$indexKey '.1.3.6.1.2.1.2.2.1.5.'.$indexKey
); );
@ -1123,7 +1117,6 @@ class AgentWizard extends HTML
// [1] => [wmi/wmic.c:196:main()] ERROR: Login to remote object. // [1] => [wmi/wmic.c:196:main()] ERROR: Login to remote object.
// If execution gone fine. // If execution gone fine.
if ($execCorrect === true) { if ($execCorrect === true) {
hd('obtiene module blocks2', true);
$this->moduleBlocks = $this->getModuleBlocks(); $this->moduleBlocks = $this->getModuleBlocks();
} else { } else {
$this->message['type'][] = 'error'; $this->message['type'][] = 'error';
@ -2413,8 +2406,7 @@ class AgentWizard extends HTML
private function resultsInterfaceWizard() private function resultsInterfaceWizard()
{ {
$generalInterfaceModules = $this->getInterfacesModules(); $generalInterfaceModules = $this->getInterfacesModules();
// hd($generalInterfaceModules, true);
// TRAZA6 (ver si aqui llega todo bien seteado o si por el contrario se jode a partir de este punto)
$generalInterfaceTables = []; $generalInterfaceTables = [];
$generalInterfaceModulesUpdated = []; $generalInterfaceModulesUpdated = [];
$component_id_number = 0; $component_id_number = 0;
@ -2477,8 +2469,7 @@ class AgentWizard extends HTML
} }
$generalInterfaceTables[0]['data'] = $generalInterfaceModulesUpdated; $generalInterfaceTables[0]['data'] = $generalInterfaceModulesUpdated;
// hd("GENERAL1", true);
// hd($generalInterfaceTables, true);
// General Default monitoring. // General Default monitoring.
html_print_div( html_print_div(
[ [
@ -2662,8 +2653,6 @@ class AgentWizard extends HTML
$interfaceTables[$interface['name']]['data'] = $interfaceModulesUpdated; $interfaceTables[$interface['name']]['data'] = $interfaceModulesUpdated;
} }
hd('GENERAL22222', true);
hd($interfaceTables, true);
html_print_div( html_print_div(
[ [
'class' => 'wizard wizard-result', 'class' => 'wizard wizard-result',
@ -2976,7 +2965,6 @@ class AgentWizard extends HTML
{ {
$moduleBlocks = $this->moduleBlocks; $moduleBlocks = $this->moduleBlocks;
// TRAZA1: hd($moduleBlocks, true); /// COMPROBAR QUE moduleBlocks NO ESTÁ VACÍO.
$blockTables = []; $blockTables = [];
// Lets work with the modules. // Lets work with the modules.
foreach ($moduleBlocks as $k => $module) { foreach ($moduleBlocks as $k => $module) {
@ -3001,7 +2989,6 @@ class AgentWizard extends HTML
// Common for FIXED Scan types. // Common for FIXED Scan types.
// If _nameOID_ macro exists, stablish the name getted. // If _nameOID_ macro exists, stablish the name getted.
if (empty($module['name_oid']) === false) { if (empty($module['name_oid']) === false) {
hd('AQUI7', true);
$nameValue = $this->snmpGetValue($module['name_oid']); $nameValue = $this->snmpGetValue($module['name_oid']);
$moduleBlocks[$k]['name'] = str_replace( $moduleBlocks[$k]['name'] = str_replace(
'_nameOID_', '_nameOID_',
@ -3016,8 +3003,6 @@ class AgentWizard extends HTML
$module['value'] = 0; $module['value'] = 0;
} }
hd('AQUI8', true);
// TRAZA3: hd($module['value'], true); /// COMPROBAR SI $module['value'] ESTÁ VACÍO.
$value = $this->snmpGetValue($module['value']); $value = $this->snmpGetValue($module['value']);
// If the value is missing, we must not show this module. // If the value is missing, we must not show this module.
@ -3031,8 +3016,6 @@ class AgentWizard extends HTML
); );
} }
hd('TRAZA2', true);
// TRAZA2: hd($moduleBlocks[$k], true); /// COMPROBAR QUE current_value ESTÁ VACÍO.
// $moduleBlocks[$k]['current_value'] = 'blablabla'; // $moduleBlocks[$k]['current_value'] = 'blablabla';
$moduleBlocks[$k]['macros'] = ''; $moduleBlocks[$k]['macros'] = '';
} else { } else {
@ -3044,7 +3027,6 @@ class AgentWizard extends HTML
// OIDs and get his values. // OIDs and get his values.
foreach ($macros as $key => $oid) { foreach ($macros as $key => $oid) {
if (preg_match('/extra_field_/', $key) !== 0) { if (preg_match('/extra_field_/', $key) !== 0) {
hd('AQUI9', true);
$value = (float) $this->snmpGetValue($oid); $value = (float) $this->snmpGetValue($oid);
// If the value not exists, // If the value not exists,
@ -3164,7 +3146,6 @@ class AgentWizard extends HTML
foreach ($oids as $oidName => $oid) { foreach ($oids as $oidName => $oid) {
$currentOid = $oid.'.'.$tmpSecond[0]; $currentOid = $oid.'.'.$tmpSecond[0];
$macros['macros'][$oidName] = $currentOid; $macros['macros'][$oidName] = $currentOid;
hd('AQUI10', true);
$currentOidValue = $this->snmpGetValue($currentOid); $currentOidValue = $this->snmpGetValue($currentOid);
// If for any reason the value comes empty, add 1. // If for any reason the value comes empty, add 1.
if ($currentOidValue == '') { if ($currentOidValue == '') {
@ -3318,7 +3299,7 @@ class AgentWizard extends HTML
$fields, $fields,
$whereString $whereString
); );
// hd(db_get_all_rows_sql($sql), true);
return db_get_all_rows_sql($sql); return db_get_all_rows_sql($sql);
} }
@ -4216,15 +4197,15 @@ class AgentWizard extends HTML
$module['current_value'] = 'NO DATA'; $module['current_value'] = 'NO DATA';
} }
$data[5] = ui_print_truncate_text( $data[5] = ui_print_truncate_text(
io_safe_output($module['current_value']), io_safe_output($module['current_value']),
20, 20,
false, false,
true, true,
true, true,
'…', '…',
false false
); );
// Activation column. // Activation column.
$data[6] = html_print_checkbox_switch_extended( $data[6] = html_print_checkbox_switch_extended(
@ -4536,7 +4517,6 @@ class AgentWizard extends HTML
$inv_critical = false; $inv_critical = false;
} }
// TRAZA5 hd($name); (ver si llega aquí Y valor de $name)
$moduleName = $name.'ifOperStatus'; $moduleName = $name.'ifOperStatus';
$definition['ifOperStatus'] = [ $definition['ifOperStatus'] = [
'module_name' => $moduleName, 'module_name' => $moduleName,