forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ubiquiti Airfiber60 (librenms#13680)
* 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
Showing
10 changed files
with
2,699 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.