Skip to content

Commit

Permalink
Ubiquiti Airfiber60 (librenms#13680)
Browse files Browse the repository at this point in the history
* Add ubiquiti Airfiber 60

* New AF60 data and MIB

* Stylci fix and small additions

* Update test data

* Stylefix

* Remove the weird ubiquity oids containing encoded mac addresses

* Updated test data

* Remove more complex sensors for now to be added after the conflict airos airos-af60 is solved

* Fix hardware and OS

* To be verified is this is the most practical / clean way of doing it

* Advanced wireless and MCS state sensor

* Fix link capacity multiplier and active link

* Test data update fix lint

* Maybe better
  • Loading branch information
jepke authored Jan 30, 2022
1 parent b6a8b60 commit 2dbfdda
Show file tree
Hide file tree
Showing 10 changed files with 2,699 additions and 10 deletions.
94 changes: 94 additions & 0 deletions LibreNMS/OS/AirosAf60.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace LibreNMS\OS;

use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\OSDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessDistanceDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessFrequencyDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRateDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
use LibreNMS\OS;

class AirosAf60 extends OS implements
OSDiscovery,
WirelessFrequencyDiscovery,
WirelessDistanceDiscovery,
WirelessRateDiscovery,
WirelessRssiDiscovery,
WirelessSnrDiscovery
{
/**
* Discover wireless frequency. This is in GHz. Type is frequency.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessFrequency()
{
$oid = '.1.3.6.1.4.1.41112.1.11.1.1.2.1'; // UI-AF60-MIB::af60Frequency.1

return [
new WirelessSensor('frequency', $this->getDeviceId(), $oid, 'airos-af60', 1, 'Radio Frequency'),
];
}

public function discoverWirelessDistance()
{
$sensors = [];

$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaRemoteDistance', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb');

foreach ($oids as $index => $entry) {
$sensors[] = new WirelessSensor('distance', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.15.' . $index, 'airos-af60', 1, 'Distance', $entry['af60StaRemoteDistance'], 1, 1000); //UI-AF60-MIB::af60StaRemoteDistance
}

return $sensors;
}

public function discoverWirelessRate()
{
$sensors = [];

$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaTxCapacity', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb');
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaRxCapacity', $oids, 'UI-AF60-MIB', 'ubnt', '-OteQUsb');

foreach ($oids as $index => $entry) {
$sensors[] = new WirelessSensor('rate', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.7.' . $index, 'airos-af60-TX', 1, 'Tx Capacity', $entry['af60StaTxCapacity'], 1000); //UI-AF60-MIB::af60StaTxCapacity
$sensors[] = new WirelessSensor('rate', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.8.' . $index, 'airos-af60-RX', 1, 'Rx Capacity', $entry['af60StaRxCapacity'], 1000); //UI-AF60-MIB::af60StaRxCapacity
}

return $sensors;
}

public function discoverWirelessRssi()
{
$sensors = [];

$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaRSSI', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb');
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaRemoteRSSI', $oids, 'UI-AF60-MIB', 'ubnt', '-OteQUsb');

foreach ($oids as $index => $entry) {
$sensors[] = new WirelessSensor('rssi', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.3.' . $index, 'airos-af60-l', 1, 'Local RSSI', $entry['af60StaRSSI'], 1); //UI-AF60-MIB::af60StaRSSI
$sensors[] = new WirelessSensor('rssi', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.18.' . $index, 'airos-af60-r', 1, 'Remote RSSI', $entry['af60StaRemoteRSSI'], 1); //UI-AF60-MIB::af60StaRemoteRSSI
}

return $sensors;
}

public function discoverWirelessSnr()
{
$sensors = [];

$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaSNR', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb');
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'af60StaRemoteSNR', $oids, 'UI-AF60-MIB', 'ubnt', '-OteQUsb');

foreach ($oids as $index => $entry) {
$sensors[] = new WirelessSensor('snr', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.4.' . $index, 'airos-af60-l', 1, 'Local SNR', $entry['af60StaSNR'], 1); //UI-AF60-MIB::af60StaSNR
$sensors[] = new WirelessSensor('snr', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.11.1.3.1.19.' . $index, 'airos-af60-r', 1, 'Remote SNR', $entry['af60StaRemoteSNR'], 1); //UI-AF60-MIB::af60StaRemoteSNR
}

return $sensors;
}
}
8 changes: 8 additions & 0 deletions doc/Developing/os/Initial-Detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ is the preferred method for detection. Other options are available:
matches one of the regex statements under this item
- `snmpget` Do not use this unless none of the other methods
work. Fetch an oid and compare it against a value.
```yaml
discovery:
-
snmpget:
- oid: <someoid>
- op: <["=","!=","==","!==","<=",">=","<",">","starts","ends","contains","regex","not_starts","not_ends","not_contains","not_regex","in_array","not_in_array","exists"]>
- value: <'string' | boolean>
```
- `_except` You can add this to any of the above to exclude that
element. As an example:

Expand Down
22 changes: 22 additions & 0 deletions includes/definitions/airos-af60.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
os: airos-af60
text: 'Ubiquiti AirFiber 60'
type: wireless
icon: ubiquiti
snmp_bulk: false
mib_dir: ubnt
over:
- { graph: device_bits, text: 'Device Traffic' }
- { graph: device_wireless_rate, text: 'Wireless Rate' }
- { graph: device_processor, text: 'CPU Usage' }
poller_modules:
wifi: true
discovery:
-
sysObjectID:
- .1.3.6.1.4.1.10002.1
- .1.3.6.1.4.1.41112.1.11.1
sysDescr: Linux
snmpget:
oid: UI-AF60-MIB::af60FirmwareVersion.1
op: '!='
value: false
4 changes: 4 additions & 0 deletions includes/definitions/airos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ discovery:
- .1.3.6.1.4.1.10002.1
- .1.3.6.1.4.1.41112.1.4
sysDescr: Linux
snmpget:
oid: UI-AF60-MIB::af60Role.1
op: '='
value: false
57 changes: 57 additions & 0 deletions includes/definitions/discovery/airos-af60.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
mib: UI-AF60-MIB
modules:
os:
hardware: UI-AF60-MIB::af60DevModel.1
version: UI-AF60-MIB::af60FirmwareVersion.1
lat: UI-AF60-MIB::af60GpsLat.1
long: UI-AF60-MIB::af60GpsLon.1
processors:
data:
-
oid: af60CpuUsage
num_oid: '.1.3.6.1.4.1.41112.1.11.2.6'
sensors:
state:
data:
-
oid: af60Role
num_oid: '.1.3.6.1.4.1.41112.1.11.1.1.1.{{ $index }}'
index: af60Role
descr: Radio Role
state_name: af60Role
states:
- { value: 0, generic: 0, graph: 0, descr: AP }
- { value: 1, generic: 0, graph: 0, descr: CPE }
-
oid: af60GpsStatus
num_oid: '.1.3.6.1.4.1.41112.1.11.1.4.1.{{ $index }}'
index: af60GpsStatus
descr: GPS Status
state_name: af60GpsStatus
states:
- { value: 0, generic: 1, graph: 0, descr: Absent }
- { value: 1, generic: 1, graph: 0, descr: Off }
- { value: 2, generic: 0, graph: 0, descr: On }
-
oid: af60GpsFix
num_oid: '.1.3.6.1.4.1.41112.1.11.1.4.2.{{ $index }}'
index: af60GpsFix
descr: GPS fix
state_name: af60GpsFix
states:
- { value: 0, generic: 1, graph: 0, descr: Unknown }
- { value: 1, generic: 1, graph: 0, descr: Nofix }
- { value: 2, generic: 0, graph: 0, descr: Fix2d }
- { value: 3, generic: 0, graph: 0, descr: Fix3d }
count:
data:
-
oid: af60GpsSatsVisible
num_oid: '.1.3.6.1.4.1.41112.1.11.1.4.7.{{ $index }}'
index: af60GpsSatsVisible
descr: Sat visible
-
oid: af60GpsSatsTracked
num_oid: '.1.3.6.1.4.1.41112.1.11.1.4.8.{{ $index }}'
index: af60GpsSatsTracked
descr: Sat tracked
77 changes: 77 additions & 0 deletions includes/discovery/sensors/state/airos-af60.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

$oids = snmpwalk_cache_oid($device, 'af60StaTxMCS', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb'); //UBNT-AFLTU-MIB::afLTUStaTxRate
$oids = snmpwalk_cache_oid($device, 'af60StaRxMCS', $oids, 'UI-AF60-MIB', 'ubnt', '-OteQUsb'); //UBNT-AFLTU-MIB::afLTUStaRxRate

foreach ($oids as $index => $entry) {
//Create State Index
$txmcs_state_name = 'af60StaTxMCS';
$rxmcs_state_name = 'af60StaRxMCS';

$rate_states = [
['value' => 1, 'generic' => 2, 'graph' => 1, 'descr' => '1X'],
['value' => 2, 'generic' => 2, 'graph' => 1, 'descr' => '2X'],
['value' => 3, 'generic' => 1, 'graph' => 1, 'descr' => '3X'],
['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => '4X'],
['value' => 5, 'generic' => 0, 'graph' => 1, 'descr' => '5X'],
['value' => 6, 'generic' => 0, 'graph' => 1, 'descr' => '6X'],
['value' => 7, 'generic' => 0, 'graph' => 1, 'descr' => '7X'],
['value' => 8, 'generic' => 0, 'graph' => 1, 'descr' => '8X'],
['value' => 9, 'generic' => 0, 'graph' => 1, 'descr' => '9X'],
];

create_state_index($txmcs_state_name, $rate_states);
create_state_index($rxmcs_state_name, $rate_states);

//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, '.1.3.6.1.4.1.41112.1.11.1.3.1.5.' . $index, 1, $txmcs_state_name, 'TX MCS Rate', '1', '1', null, null, null, null, $entry['af60StaTxMCS']);
discover_sensor($valid['sensor'], 'state', $device, '.1.3.6.1.4.1.41112.1.11.1.3.1.6.' . $index, 2, $rxmcs_state_name, 'RX MCS Rate', '1', '1', null, null, null, null, $entry['af60StaRxMCS']);

//Create Sensor To State Index
create_sensor_to_state_index($device, $txmcs_state_name, 1);
create_sensor_to_state_index($device, $rxmcs_state_name, 2);

break;
}

unset(
$oids,
$index,
$entry,
$rate_states,
$txmcs_state_name,
$rxmcs_state_name
);

$oids = snmpwalk_cache_oid($device, 'af60StaActiveLink', [], 'UI-AF60-MIB', 'ubnt', '-OteQUsb'); //UBNT-AFLTU-MIB::afLTUStaTxRate
// This returns either "main" or "backup" as a string

foreach ($oids as $index => $entry) {
// convert string to int main === 1 and backup === 2
$entry['af60StaActiveLink'] = $entry['af60StaActiveLink'] === 'main' ? 1 : 2;
//Create State Index
$activeLink_state_name = 'af60StaActiveLink';

$rate_states = [
['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'Main'],
['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'Backup'],
];

create_state_index($activeLink_state_name, $rate_states);

//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, '.1.3.6.1.4.1.41112.1.11.1.3.1.2.' . $index, 1, $activeLink_state_name, 'Active link', '1', '1', null, null, null, null, $entry['af60StaActiveLink']);

//Create Sensor To State Index
create_sensor_to_state_index($device, $activeLink_state_name, 1);

break;
}

unset(
$oids,
$index,
$entry,
$rate_states,
$activeLink_state_name
);
22 changes: 12 additions & 10 deletions mibs/ubnt/UBNT-MIB
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ UBNT-MIB DEFINITIONS ::= BEGIN
OBJECT-GROUP, MODULE-COMPLIANCE FROM SNMPv2-CONF;

ubntMIB MODULE-IDENTITY
LAST-UPDATED "201402270000Z"
ORGANIZATION "Ubiquiti Networks, Inc."
CONTACT-INFO "support@ubnt.com"
DESCRIPTION "The MIB module for Ubiquiti Networks, Inc. entities"
REVISION "201402270000Z"
LAST-UPDATED "202109210000Z"
ORGANIZATION "Ubiquiti, Inc."
CONTACT-INFO "support@ui.com"
DESCRIPTION "The MIB module for Ubiquiti, Inc. entities"
REVISION "202109210000Z"
DESCRIPTION "Split revision"
::= { ubnt 1 }

-- --------------------------------------------------------------------------------
-- Ubiquiti Networks Root
-- Ubiquiti Root
-- --------------------------------------------------------------------------------

ubnt OBJECT IDENTIFIER ::= { enterprises 41112 }

-- --------------------------------------------------------------------------------
-- Ubiquiti Networks SNMP Information
-- Ubiquiti SNMP Information
-- --------------------------------------------------------------------------------

ubntSnmpInfo OBJECT IDENTIFIER ::= { ubntMIB 2 }
Expand All @@ -33,21 +33,23 @@ UBNT-MIB DEFINITIONS ::= BEGIN
ubntMFiGroups OBJECT IDENTIFIER ::= { ubntSnmpInfo 7}
ubntUniTelGroups OBJECT IDENTIFIER ::= { ubntSnmpInfo 8}
ubntAFLTUGroups OBJECT IDENTIFIER ::= { ubntSnmpInfo 9}
uiAF60Groups OBJECT IDENTIFIER ::= { ubntSnmpInfo 10}

-- --------------------------------------------------------------------------------
-- Ubiquiti Networks Products
-- Ubiquiti Products
-- --------------------------------------------------------------------------------

ubntAirFIBER OBJECT IDENTIFIER ::= { ubntMIB 3 }
ubntEdgeMax OBJECT IDENTIFIER ::= { ubntMIB 5 }
ubntUniFi OBJECT IDENTIFIER ::= { ubntMIB 6 }
ubntAirVision OBJECT IDENTIFIER ::= { ubntMIB 7 }
ubntMFi OBJECT IDENTIFIER ::= { ubntMIB 8 }
ubntUniTel OBJECT IDENTIFIER ::= { ubntMIB 9 }
ubntAFLTU OBJECT IDENTIFIER ::= { ubntMIB 10 }
uiAF60 OBJECT IDENTIFIER ::= { ubntMIB 11 }

-- --------------------------------------------------------------------------------
-- Ubiquiti Networks OR table
-- Ubiquiti OR table
-- --------------------------------------------------------------------------------

ubntORTable OBJECT-TYPE
Expand Down
Loading

0 comments on commit 2dbfdda

Please sign in to comment.