More Replacement Capabilities for sensor index computation (#14522)

* More Replacement Cap.

style

* more compact

* fix mni.yaml

* too compact, revert

* quantastor

* str_replace was never matched
This commit is contained in:
PipoCanaja
2022-11-02 22:54:40 +01:00
committed by GitHub
parent 51fcd8f6a0
commit ce6eaadc2a
4 changed files with 718 additions and 592 deletions

View File

@@ -968,7 +968,15 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
$value = $user_function($value);
}
$uindex = str_replace('{{ $index }}', $index, isset($data['index']) ? $data['index'] : $index);
$uindex = $index;
if (isset($data['index'])) {
if (Str::contains($data['index'], '{{')) {
$uindex = trim(YamlDiscovery::replaceValues('index', $index, null, $data, $pre_cache));
} else {
$uindex = $data['index'];
}
}
discover_sensor($valid['sensor'], $sensor_class, $device, $oid, $uindex, $sensor_name, $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $value, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured, $user_function, $group, $data['rrd_type']);
if ($sensor_class === 'state') {