Zyxel AP wireless client discovery enhancement (#14704)

* Update Zyxelnwa.php

Discovering wireless clients on all bands

* Update ZYXEL-ES-WIRELESS

Replace '_' by '-' as it is a bad practice to use underscores in values

* Update Zyxelnwa.php

* Update ZYXEL-ES-WIRELESS

* Update zyxelnwa.snmprec

* Create zyxelnwa.json

* Update Zyxelnwa.php

* Update zyxelnwa.snmprec

* Update ZYXEL-ES-WIRELESS

* Update Zyxelnwa.php

* Update zyxelnwa.snmprec

* Update Zyxelnwa.php

* Update Zyxelnwa.php

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Gerald VINCENT
2023-11-06 07:43:59 +01:00
committed by GitHub
parent fa93034edd
commit 11903150c8
4 changed files with 502 additions and 14 deletions

View File

@ -19,16 +19,64 @@ namespace LibreNMS\OS;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\OSDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessFrequencyDiscovery;
use LibreNMS\Interfaces\Polling\Sensors\WirelessFrequencyPolling;
use LibreNMS\OS\Shared\Zyxel;
class Zyxelnwa extends Zyxel implements OSDiscovery, WirelessClientsDiscovery
class Zyxelnwa extends Zyxel implements OSDiscovery, WirelessClientsDiscovery, WirelessFrequencyDiscovery, WirelessFrequencyPolling
{
public function discoverWirelessClients()
{
$oid = '.1.3.6.1.4.1.890.1.15.3.5.1.1.2.1'; //ZYXEL-ES-SMI::esMgmt.5.1.1.2.1
$sensors = [];
$base_oid = '.1.3.6.1.4.1.890.1.15.3.5.1.1.2.'; // ZYXEL-ES-WIRELESS::wlanStationCount
return [
new WirelessSensor('clients', $this->getDeviceId(), $oid, 'zyxelnwa', 1, 'Clients'),
];
foreach ($this->getWlanRadioTable() as $index => $row) {
$radio = $this->getRadioName($row['ZYXEL-ES-WIRELESS::wlanMode']);
$sensors[] = new WirelessSensor('clients', $this->getDeviceId(), $base_oid . $index, 'zyxelnwa', $index, $radio, $row['ZYXEL-ES-WIRELESS::wlanStationCount']);
}
$total = \SnmpQuery::options(['-OQXUte', '-Pu'])->get('ZYXEL-ES-WIRELESS::wlanTotalStationCount.0')->value();
if ($total !== '') {
$sensors[] = new WirelessSensor('clients', $this->getDeviceId(), '.1.3.6.1.4.1.890.1.15.3.5.15.0', 'zyxelnwa', 'total', 'Total', (int) $total);
}
return $sensors;
}
public function discoverWirelessFrequency()
{
$sensors = [];
$base_oid = '.1.3.6.1.4.1.890.1.15.3.5.1.1.6.'; // ZYXEL-ES-WIRELESS::wlanChannel
foreach ($this->getWlanRadioTable() as $index => $row) {
$radio = $this->getRadioName($row['ZYXEL-ES-WIRELESS::wlanMode']);
$frequency = WirelessSensor::channelToFrequency($row['ZYXEL-ES-WIRELESS::wlanChannel']);
$sensors[] = new WirelessSensor('frequency', $this->getDeviceId(), $base_oid . $index, 'zyxelnwa', $index, $radio, $frequency);
}
return $sensors;
}
public function pollWirelessFrequency(array $sensors)
{
return $this->pollWirelessChannelAsFrequency($sensors);
}
private function getRadioName($value): string
{
return match ($value) {
'1' => '2.4GHz',
'2' => '5GHz',
'3' => '6GHz',
default => 'Unknown',
};
}
private function getWlanRadioTable()
{
return \SnmpQuery::options(['-OQXUte', '-Pu']) // ignore underscores
->cache()
->walk('ZYXEL-ES-WIRELESS::wlanRadioTable')
->table(1);
}
}

View File

@ -26,12 +26,12 @@ IMPORTS
--
-- Node: esWireless
-- includes wlanRadioTable, wlanStationTable, wlanStatisticsTable, wlanTraps
-- includes wlanRadioTable, wlanStationTable, wlanStatisticsTable, wlanTraps, wlanTotalStationCount
--
esWireless MODULE-IDENTITY
LAST-UPDATED "201009200000Z"
ORGANIZATION "Enterprise Solution ZyXEL"
ORGANIZATION "Enterprise Solution Zyxel"
CONTACT-INFO ""
DESCRIPTION
"The sub tree for Wireless information"
@ -56,7 +56,7 @@ wlanRadioEntry OBJECT-TYPE
STATUS current
DESCRIPTION
"An entry describing WLAN Radio information for each chip."
INDEX {ifIndex }
INDEX { wlanRadioIndex }
::= { wlanRadioTable 1 }
WlanRadioEntry ::= SEQUENCE {
@ -65,6 +65,7 @@ WlanRadioEntry ::= SEQUENCE {
wlanSupportedChannel OCTET STRING,
wlanMode INTEGER,
wlanChannel INTEGER,
wlanRadioIndex Integer32
}
wlanCurrentChannel OBJECT-TYPE
@ -107,7 +108,67 @@ WlanRadioEntry ::= SEQUENCE {
channel-153_5765mhz(153),
channel-157_5785mhz(157),
channel-161_5805mhz(161),
channel-165_5825mhz(165)
channel-165_5825mhz(165),
channel-01_5955mhz(1),
channel-05_5975mhz(5),
channel-09_5995mhz(9),
channel-13_6015mhz(13),
channel-17_6035mhz(17),
channel-21_6055mhz(21),
channel-25_6075mhz(25),
channel-29_6095mhz(29),
channel-33_6115mhz(33),
channel-37_6135mhz(37),
channel-41_6155mhz(41),
channel-45_6175mhz(45),
channel-49_6195mhz(49),
channel-53_6215mhz(53),
channel-57_6235mhz(57),
channel-61_6255mhz(51),
channel-65_6275mhz(55),
channel-69_6295mhz(69),
channel-73_6315mhz(73),
channel-77_6335mhz(77),
channel-81_6355mhz(81),
channel-85_6375mhz(85),
channel-89_6395mhz(89),
channel-93_6415mhz(93),
channel-97_6435mhz(97),
channel-101_6455mhz(101),
channel-105_6475mhz(105),
channel-109_6495mhz(109),
channel-113_6515mhz(113),
channel-117_6535mhz(117),
channel-121_6555mhz(121),
channel-125_6575mhz(125),
channel-129_6595mhz(129),
channel-133_6615mhz(133),
channel-137_6635mhz(137),
channel-141_6655mhz(141),
channel-145_6675mhz(145),
channel-149_6695mhz(149),
channel-153_6715mhz(153),
channel-157_6735mhz(157),
channel-161_6755mhz(161),
channel-165_6775mhz(165),
channel-169_6795mhz(169),
channel-173_6815mhz(173),
channel-177_6835mhz(177),
channel-181_6855mhz(181),
channel-185_6875mhz(185),
channel-189_6895mhz(189),
channel-193_6915mhz(193),
channel-197_6935mhz(197),
channel-201_6955mhz(201),
channel-205_6975mhz(205),
channel-209_6995mhz(209),
channel-213_7015mhz(213),
channel-217_7035mhz(217),
channel-221_7055mhz(221),
channel-225_7075mhz(225),
channel-229_7095mhz(229),
channel-233_7115mhz(233)
}
MAX-ACCESS read-only
STATUS current
@ -134,7 +195,8 @@ WlanRadioEntry ::= SEQUENCE {
wlanMode OBJECT-TYPE
SYNTAX INTEGER {
mode_2_4G(1),
mode_5G(2)
mode_5G(2),
mode_6G(3)
}
MAX-ACCESS read-write
STATUS current
@ -181,7 +243,67 @@ WlanRadioEntry ::= SEQUENCE {
channel-153_5765mhz(153),
channel-157_5785mhz(157),
channel-161_5805mhz(161),
channel-165_5825mhz(165)
channel-165_5825mhz(165),
channel-01_5955mhz(1),
channel-05_5975mhz(5),
channel-09_5995mhz(9),
channel-13_6015mhz(13),
channel-17_6035mhz(17),
channel-21_6055mhz(21),
channel-25_6075mhz(25),
channel-29_6095mhz(29),
channel-33_6115mhz(33),
channel-37_6135mhz(37),
channel-41_6155mhz(41),
channel-45_6175mhz(45),
channel-49_6195mhz(49),
channel-53_6215mhz(53),
channel-57_6235mhz(57),
channel-61_6255mhz(51),
channel-65_6275mhz(55),
channel-69_6295mhz(69),
channel-73_6315mhz(73),
channel-77_6335mhz(77),
channel-81_6355mhz(81),
channel-85_6375mhz(85),
channel-89_6395mhz(89),
channel-93_6415mhz(93),
channel-97_6435mhz(97),
channel-101_6455mhz(101),
channel-105_6475mhz(105),
channel-109_6495mhz(109),
channel-113_6515mhz(113),
channel-117_6535mhz(117),
channel-121_6555mhz(121),
channel-125_6575mhz(125),
channel-129_6595mhz(129),
channel-133_6615mhz(133),
channel-137_6635mhz(137),
channel-141_6655mhz(141),
channel-145_6675mhz(145),
channel-149_6695mhz(149),
channel-153_6715mhz(153),
channel-157_6735mhz(157),
channel-161_6755mhz(161),
channel-165_6775mhz(165),
channel-169_6795mhz(169),
channel-173_6815mhz(173),
channel-177_6835mhz(177),
channel-181_6855mhz(181),
channel-185_6875mhz(185),
channel-189_6895mhz(189),
channel-193_6915mhz(193),
channel-197_6935mhz(197),
channel-201_6955mhz(201),
channel-205_6975mhz(205),
channel-209_6995mhz(209),
channel-213_7015mhz(213),
channel-217_7035mhz(217),
channel-221_7055mhz(221),
channel-225_7075mhz(225),
channel-229_7095mhz(229),
channel-233_7115mhz(233)
}
MAX-ACCESS read-write
STATUS current
@ -189,6 +311,14 @@ WlanRadioEntry ::= SEQUENCE {
"The control for WLAN channel. When setting this
parameter, the value should be a subset of all supported channel"
::= { wlanRadioEntry 6 }
wlanRadioIndex OBJECT-TYPE
SYNTAX Integer32 (1..2147483647)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Index of WLAN Radio information for each chip."
::= { wlanRadioEntry 7 }
--
@ -216,7 +346,8 @@ WlanStationEntry ::= SEQUENCE {
stationIndex Integer32,
stationMacAddress MacAddress,
stationAssociatedTime DateAndTime,
stationSSID OCTET STRING
stationSSID OCTET STRING,
stationSignalStrength OCTET STRING
}
stationIndex OBJECT-TYPE
@ -252,6 +383,14 @@ WlanStationEntry ::= SEQUENCE {
"The associated ssid."
::= { wlanStationEntry 4 }
stationSignalStrength OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Stations singal Strength (dbm)."
::= { wlanStationEntry 5 }
--
-- Node: wlanStatistics
@ -271,7 +410,7 @@ wlanStatisticsEntry OBJECT-TYPE
STATUS current
DESCRIPTION
"An entry describing WLAN statistics information."
INDEX { ifIndex }
INDEX { wlanStatisticsIndex }
::= { wlanStatisticsTable 1 }
WlanStatisticsEntry ::= SEQUENCE {
@ -281,7 +420,8 @@ WlanStatisticsEntry ::= SEQUENCE {
dot11ReceivedFragmentCount Counter64,
dot11TransmittedFrameCount Counter64,
dot11ReceivedPktCount Counter64,
dot11TransmittedPktCount Counter64
dot11TransmittedPktCount Counter64,
wlanStatisticsIndex Integer32
}
dot11FailedCount OBJECT-TYPE
@ -344,6 +484,14 @@ WlanStatisticsEntry ::= SEQUENCE {
DESCRIPTION
"This counter shall increment for each successfully transmitted packets."
::= { wlanStatisticsEntry 7 }
wlanStatisticsIndex OBJECT-TYPE
SYNTAX Integer32 (1..2147483647)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Index of WLAN statistics information."
::= { wlanStatisticsEntry 8 }
--
@ -433,4 +581,15 @@ WlanStatisticsEntry ::= SEQUENCE {
"Wireless client authentication failed."
::= { trapsItems 3 }
--
-- Node: wlanTotalStationCount
--
wlanTotalStationCount OBJECT-TYPE
SYNTAX INTEGER
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The total numbers of associated stations"
::= { esWireless 15 }
END

271
tests/data/zyxelnwa.json Normal file
View File

@ -0,0 +1,271 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": null,
"sysObjectID": ".1.3.6.1.4.1.890.1.15",
"sysDescr": "NWA-",
"sysContact": null,
"version": null,
"hardware": null,
"features": null,
"location": null,
"os": "zyxelnwa",
"type": "network",
"serial": null,
"icon": "zyxel.svg"
}
]
},
"poller": "matches discovery"
},
"processors": {
"discovery": {
"processors": [
{
"entPhysicalIndex": 0,
"hrDeviceIndex": 0,
"processor_oid": ".1.3.6.1.4.1.890.1.6.22.1.1.0",
"processor_index": "0",
"processor_type": "zyxelnwa",
"processor_usage": 42,
"processor_descr": "Processor",
"processor_precision": 1,
"processor_perc_warn": 75
}
]
},
"poller": "matches discovery"
},
"wireless": {
"discovery": {
"wireless_sensors": [
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "1",
"sensor_type": "zyxelnwa",
"sensor_descr": "2.4GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 11,
"sensor_prev": null,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.2.1\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "2",
"sensor_type": "zyxelnwa",
"sensor_descr": "5GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 54,
"sensor_prev": null,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.2.2\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "total",
"sensor_type": "zyxelnwa",
"sensor_descr": "Total",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 65,
"sensor_prev": null,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.15.0\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "frequency",
"sensor_index": "1",
"sensor_type": "zyxelnwa",
"sensor_descr": "2.4GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 2427,
"sensor_prev": null,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.6.1\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "frequency",
"sensor_index": "2",
"sensor_type": "zyxelnwa",
"sensor_descr": "5GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 5620,
"sensor_prev": null,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.6.2\"]",
"rrd_type": "GAUGE"
}
]
},
"poller": {
"wireless_sensors": [
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "1",
"sensor_type": "zyxelnwa",
"sensor_descr": "2.4GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 11,
"sensor_prev": 11,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.2.1\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "2",
"sensor_type": "zyxelnwa",
"sensor_descr": "5GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 54,
"sensor_prev": 54,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.2.2\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "clients",
"sensor_index": "total",
"sensor_type": "zyxelnwa",
"sensor_descr": "Total",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 65,
"sensor_prev": 65,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.15.0\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "frequency",
"sensor_index": "1",
"sensor_type": "zyxelnwa",
"sensor_descr": "2.4GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 2427,
"sensor_prev": 2427,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.6.1\"]",
"rrd_type": "GAUGE"
},
{
"sensor_deleted": 0,
"sensor_class": "frequency",
"sensor_index": "2",
"sensor_type": "zyxelnwa",
"sensor_descr": "5GHz",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_aggregator": "sum",
"sensor_current": 5620,
"sensor_prev": 5620,
"sensor_limit": null,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
"entPhysicalIndex": null,
"entPhysicalIndex_measured": null,
"sensor_oids": "[\".1.3.6.1.4.1.890.1.15.3.5.1.1.6.2\"]",
"rrd_type": "GAUGE"
}
]
}
}
}

View File

@ -1,3 +1,13 @@
1.3.6.1.2.1.1.1.0|4|NWA-
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.890.1.15
1.3.6.1.4.1.890.1.6.22.1.1.0|2|42
1.3.6.1.4.1.890.1.15.3.5.1.1.1.1|2|4
1.3.6.1.4.1.890.1.15.3.5.1.1.2.1|2|11
1.3.6.1.4.1.890.1.15.3.5.1.1.5.1|2|1
1.3.6.1.4.1.890.1.15.3.5.1.1.6.1|2|4
1.3.6.1.4.1.890.1.15.3.5.1.1.1.2|2|124
1.3.6.1.4.1.890.1.15.3.5.1.1.2.2|2|54
1.3.6.1.4.1.890.1.15.3.5.1.1.5.2|2|2
1.3.6.1.4.1.890.1.15.3.5.1.1.6.2|2|124
1.3.6.1.4.1.890.1.15.3.5.15.0|2|65
1.3.6.1.4.1.890.1.99.0|2|1