Fixed issue with id_plugin with bandwidth modules

This commit is contained in:
José González 2021-05-27 22:06:58 +02:00
parent 44656b9d65
commit 91e870edbc

View File

@ -312,7 +312,7 @@ class AgentWizard extends HTML
$this->idPolicy = get_parameter('id', ''); $this->idPolicy = get_parameter('id', '');
$this->targetIp = get_parameter('targetIp', ''); $this->targetIp = get_parameter('targetIp', '');
if (!empty($this->idAgent)) { if (empty($this->idAgent) === false) {
$array_aux = db_get_all_rows_sql( $array_aux = db_get_all_rows_sql(
sprintf( sprintf(
'SELECT ip FROM taddress ta 'SELECT ip FROM taddress ta
@ -1687,28 +1687,43 @@ class AgentWizard extends HTML
) )
); );
if ($fieldsPlugin !== false) { if ($this->wizardSection === 'snmp_interfaces_explorer'
$fieldsPlugin = json_decode($fieldsPlugin, true); && empty($candidate['macros']) === false
$i = 1; ) {
foreach ($infoMacros as $key => $value) { // Use definition provided.
if (empty(preg_match('/_snmp_field/', $key)) === false) { $values['id_plugin'] = $candidate['id_plugin'];
$new_macros = []; $values['macros'] = base64_decode($candidate['macros']);
foreach ($fieldsPlugin as $k => $v) { } else {
if ($v['macro'] === preg_replace('/_snmp_field/', '', $key)) { $fieldsPlugin = db_get_value_sql(
$fieldsPlugin[$k]['value'] = $this->replacementMacrosPlugin( sprintf(
$value, 'SELECT macros FROM tplugin WHERE id=%d',
$infoMacros['macros'] (int) $infoMacros['server_plugin']
); )
$i++; );
continue;
if ($fieldsPlugin !== false) {
$fieldsPlugin = json_decode($fieldsPlugin, true);
$i = 1;
foreach ($infoMacros as $key => $value) {
if (empty(preg_match('/_snmp_field/', $key)) === false) {
$new_macros = [];
foreach ($fieldsPlugin as $k => $v) {
if ($v['macro'] === preg_replace('/_snmp_field/', '', $key)) {
$fieldsPlugin[$k]['value'] = $this->replacementMacrosPlugin(
$value,
$infoMacros['macros']
);
$i++;
continue;
}
} }
} }
} }
} }
}
$values['id_plugin'] = $infoMacros['server_plugin']; $values['id_plugin'] = $infoMacros['server_plugin'];
$values['macros'] = json_encode($fieldsPlugin); $values['macros'] = json_encode($fieldsPlugin);
}
} }
} }
} else if ($this->protocol === 'wmi') { } else if ($this->protocol === 'wmi') {