mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix Unifi processors (#12854)
Use HOST-RESOURCES-MIB, apparently Ubiquiti added partial HR-MIB support sometime. Works better than the old load based value. Also port os discovery to the new style
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace LibreNMS\OS;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Device\WirelessSensor;
|
||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessCcqDiscovery;
|
||||
@@ -45,10 +46,37 @@ class Unifi extends OS implements
|
||||
WirelessPowerDiscovery,
|
||||
WirelessUtilizationDiscovery
|
||||
{
|
||||
use OS\Traits\FrogfootResources;
|
||||
use OS\Traits\FrogfootResources {
|
||||
OS\Traits\FrogfootResources::discoverProcessors as discoverFrogfootProcessors;
|
||||
}
|
||||
|
||||
private $ccqDivisor = 10;
|
||||
|
||||
public function discoverOS(Device $device): void
|
||||
{
|
||||
// try the Unifi MIB first, then fall back to dot11manufacturer
|
||||
if ($data = snmp_getnext_multi($this->getDeviceArray(), ['unifiApSystemModel', 'unifiApSystemVersion'], '-OQUs', 'UBNT-UniFi-MIB')) {
|
||||
$device->hardware = $data['unifiApSystemModel'] ?? $device->hardware;
|
||||
$device->version = $data['unifiApSystemVersion'] ?? $device->version;
|
||||
} elseif ($data = snmp_getnext_multi($this->getDeviceArray(), ['dot11manufacturerProductName', 'dot11manufacturerProductVersion'], '-OQUs', 'IEEE802dot11-MIB')) {
|
||||
$device->hardware = $data['dot11manufacturerProductName'] ?? $device->hardware;
|
||||
if (preg_match('/(v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/', $data['dot11manufacturerProductVersion'], $matches)) {
|
||||
$device->version = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover processors.
|
||||
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
|
||||
*
|
||||
* @return array Processors
|
||||
*/
|
||||
public function discoverProcessors()
|
||||
{
|
||||
return $this->discoverHrProcessors() ?: $this->discoverFrogfootProcessors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of LibreNMS\Device\Sensor objects
|
||||
*
|
||||
|
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ($data = snmp_getnext_multi($device, 'unifiApSystemModel unifiApSystemVersion', '-OQUs', 'UBNT-UniFi-MIB')) {
|
||||
$hardware = $data['unifiApSystemModel'];
|
||||
$version = $data['unifiApSystemVersion'];
|
||||
} elseif ($data = snmp_getnext_multi($device, 'dot11manufacturerProductName dot11manufacturerProductVersion', '-OQUs', 'IEEE802dot11-MIB')) {
|
||||
$hardware = $data['dot11manufacturerProductName'];
|
||||
if (preg_match('/(v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/', $data['dot11manufacturerProductVersion'], $matches)) {
|
||||
$version = $matches[0];
|
||||
}
|
||||
}
|
6999
tests/data/unifi_nanohd.json
Normal file
6999
tests/data/unifi_nanohd.json
Normal file
File diff suppressed because it is too large
Load Diff
1001
tests/snmpsim/unifi_nanohd.snmprec
Normal file
1001
tests/snmpsim/unifi_nanohd.snmprec
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user