Fix Undefined variable/key warnings (#14134)

* Fix Undefined variable/key warnings

* massage for test data

* restore set_numeric, only generates noise

* Fix ucd storage used (apparently free is not stored in discovery...)
This commit is contained in:
Tony Murray
2022-08-21 16:23:43 -05:00
committed by GitHub
parent ff7d89e5e4
commit 465fa3986a
33 changed files with 179 additions and 166 deletions

View File

@@ -226,7 +226,9 @@ class YamlDiscovery
$sub_index = 0;
$sub_index_end = null;
if (preg_match('/^(.+):(\d+)(?:-(\d+))?$/', $name, $matches)) {
[,$name, $sub_index, $sub_index_end] = $matches;
$name = $matches[1] ?? null;
$sub_index = $matches[2] ?? null;
$sub_index_end = $matches[3] ?? null;
}
if (isset($pre_cache[$name]) && ! is_numeric($name)) {
@@ -291,7 +293,7 @@ class YamlDiscovery
$saved_nobulk = Config::getOsSetting($os->getName(), 'snmp_bulk', true);
foreach ($data_array as $data) {
foreach ((array) $data['oid'] as $oid) {
foreach (Arr::wrap($data['oid'] ?? []) as $oid) {
if (! array_key_exists($oid, $pre_cache)) {
if (isset($data['snmp_flags'])) {
$snmp_flag = Arr::wrap($data['snmp_flags']);