Solved issue

This commit is contained in:
Jose Gonzalez 2020-10-22 17:01:10 +02:00
parent 7bd7d190c5
commit ddc46c077f

View File

@ -3002,7 +3002,7 @@ class AgentWizard extends HTML
$newModule = $module; $newModule = $module;
// Split the values got to obtain the name. // Split the values got to obtain the name.
$tmpFirst = explode('.', $value); $tmpFirst = explode('.', $value);
$tmpSecond = explode(' ', $tmpFirst[1]); $tmpSecond = explode(' ', $tmpFirst[(count($tmpFirst) - 1)]);
// Position 0 is the index, Position 3 is the MIB name. // Position 0 is the index, Position 3 is the MIB name.
$snmpwalkNames[$tmpSecond[0]] = $tmpSecond[3]; $snmpwalkNames[$tmpSecond[0]] = $tmpSecond[3];
// Perform the operations for get the values. // Perform the operations for get the values.
@ -3011,6 +3011,11 @@ class AgentWizard extends HTML
$currentOid = $oid.'.'.$tmpSecond[0]; $currentOid = $oid.'.'.$tmpSecond[0];
$macros['macros'][$oidName] = $currentOid; $macros['macros'][$oidName] = $currentOid;
$currentOidValue = $this->snmpgetValue($currentOid); $currentOidValue = $this->snmpgetValue($currentOid);
// If for any reason the value comes empty, add 1.
if ($currentOidValue == '') {
$currentOidValue = 1;
}
$thisOperation = preg_replace( $thisOperation = preg_replace(
'/'.$oidName.'/', '/'.$oidName.'/',
$currentOidValue, $currentOidValue,
@ -4739,11 +4744,11 @@ class AgentWizard extends HTML
string $unit='', string $unit='',
?int $type=0 ?int $type=0
) { ) {
// Avoid non-numeric or arithmetic chars for security reasons. try {
if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) { // Avoid non-numeric or arithmetic chars for security reasons.
$output = 'ERROR'; if (preg_match('/(([^0-9\s\+\-\*\/\(\).,])+)/', $operation) === 1) {
} else { throw new Exception(sprintf(__("The operation '%s' is not permitted. Review for remote components."), $operation));
try { } else {
// Get the result of the operation and set it. // Get the result of the operation and set it.
$output = ''; $output = '';
eval('$output = '.$operation.';'); eval('$output = '.$operation.';');
@ -4753,9 +4758,11 @@ class AgentWizard extends HTML
$unit, $unit,
$type $type
); );
} catch (Exception $e) {
$output = 'ERROR';
} }
} catch (Exception $e) {
$this->message['type'][] = 'error';
$this->message['message'][] = $e->getMessage();
$this->showMessage();
} }
return $output; return $output;