From 2ab6f63f3120d3190d949ecac2da7fa2c0337724 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 19 Feb 2021 11:37:36 -0600 Subject: [PATCH] Fix location for devices with broken snmp (#12544) AirOS devices with old firmware did not return SNMP results as they should. This compromise should minimize extra snmp queries. (Although there are more) --- LibreNMS/OS/Traits/YamlOSDiscovery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibreNMS/OS/Traits/YamlOSDiscovery.php b/LibreNMS/OS/Traits/YamlOSDiscovery.php index 16c8c03437..4375bfdbeb 100644 --- a/LibreNMS/OS/Traits/YamlOSDiscovery.php +++ b/LibreNMS/OS/Traits/YamlOSDiscovery.php @@ -83,7 +83,7 @@ trait YamlOSDiscovery public function fetchLocation(): Location { $os_yaml = $this->getDiscovery('os'); - $name = $os_yaml['location'] ?? 'SNMPv2-MIB::sysLocation.0'; + $name = $os_yaml['location'] ?? null; $lat = $os_yaml['lat'] ?? null; $lng = $os_yaml['long'] ?? null; @@ -94,7 +94,7 @@ trait YamlOSDiscovery Log::debug('Yaml location data:', $data); return new Location([ - 'location' => $this->findFirst($data, $name, $numeric), + 'location' => $this->findFirst($data, $name, $numeric) ?? snmp_get($this->getDeviceArray(), 'SNMPv2-MIB::sysLocation.0', '-Oqv'), 'lat' => $this->findFirst($data, $lat, $numeric), 'lng' => $this->findFirst($data, $lng, $numeric), ]);