Files
librenms-librenms/LibreNMS/OS/Ewc.php

313 lines
10 KiB
PHP
Raw Normal View History

<?php
/**
* Ewc.php
*
* Extreme Wireless Controller
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
2021-09-10 20:09:53 +02:00
*
* @copyright 2017 James Andrewartha
* @author James Andrewartha <trs80@ucc.asn.au>
*/
namespace LibreNMS\OS;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessErrorsDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessFrequencyDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessNoiseFloorDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessUtilizationDiscovery;
use LibreNMS\OS;
class Ewc extends OS implements
WirelessApCountDiscovery,
WirelessClientsDiscovery,
WirelessErrorsDiscovery,
WirelessFrequencyDiscovery,
WirelessNoiseFloorDiscovery,
WirelessRssiDiscovery,
WirelessSnrDiscovery,
WirelessUtilizationDiscovery
{
/**
* Discover wireless AP count.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessApCount()
{
$oids = [
'HIPATH-WIRELESS-HWC-MIB::apCount.0',
'HIPATH-WIRELESS-HWC-MIB::licenseLocalAP.0',
'HIPATH-WIRELESS-HWC-MIB::licenseForeignAP.0',
];
Convert OS discovery to new style (#12099) * terra * airos * port cisco os polling old wwan polling was broken and deprecated anyway * enterasys * Brother, a few changes * AW Plus * Fabos * set expected test data * 3com * Adva FSP150 * advantech * airos-af * aix * akcp * allied * allworx and missed mibs * anyos * fixup some zyxel shared stuffs zywall graph polling * aos * apc * apex * apsoluteos * fix copyrights * arris * arris * aruba-instant * ArubaOS * Ascom * asuswrt-merlin, ats * audiocodes * avocent * avtech * barracuda * binox * boss * canonprinter * cdata * ceraos * ciena-waveserver * fix 3com * fix airos * fix brother yaml? * fix aos more * fix and improve apc * fix arista test data * yaml discovery (basic) * cimc * mib not used * remove old discovery file * ciscosat * ciscosb fixes + improvements * comware * ctm * cumulus * cxr-ts * cyberoam-utm * cyberpower * dahua-nvr * dasan-nos * datadomain * dcn-software and fallback oids * dd-wrt * dell-laser * d* * e* and location * forti, post processing, oid coalescing * Freebsd array of sysDescr regex * finish f* * g* * h* * i* WIP * i* * Junos * j* * k* * unix refactor previous to yaml more inject $device * fixes * fixes * l* * m* * n* ability to set other fields in regex tnmsne polling to eloquent * o* * p* * q* + bonus calix * r* * s* WIP * s* * t* * u* * v* rework vrp to yaml (hybrid) * w* * x* * z* * a* easy no-data * fixes * style fixes * missed ApexPlus * fix signature * Add missing location data * rename getDevice functions * add new cisco ftd data * update docs * revert sill snmp format * fix snmp options * update for new smartax test data * rebase dsm * fix voss
2020-09-18 08:12:07 -05:00
$data = snmp_get_multi($this->getDeviceArray(), $oids);
$licCount = $data[0]['licenseLocalAP'] + $data[0]['licenseForeignAP'];
return [
new WirelessSensor(
'ap-count',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.1.0',
'ewc',
0,
'Connected APs'
),
new WirelessSensor(
'ap-count',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.1.1.0',
'ewc',
1,
'Configured APs',
$data[0]['apCount'],
1,
1,
'sum',
null,
$licCount
),
];
}
/**
* Returns an array of LibreNMS\Device\Sensor objects
*
* @return array Sensors
*/
public function discoverWirelessClients()
{
$sensors = [
new WirelessSensor(
'clients',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.6.1.0',
'ewc',
0,
'Connected Clients'
),
];
$apstats = snmpwalk_cache_oid($this->getDeviceArray(), 'apStatsMuCounts', [], 'HIPATH-WIRELESS-HWC-MIB');
$apnames = $this->getCacheByIndex('apName', 'HIPATH-WIRELESS-HWC-MIB');
foreach ($apstats as $index => $entry) {
$apStatsMuCounts = $entry['apStatsMuCounts'];
$name = $apnames[$index];
$sensors[] = new WirelessSensor(
'clients',
$this->getDeviceId(),
'1.3.6.1.4.1.4329.15.3.5.2.2.1.14.' . $index,
'ewc',
$index,
"Clients ($name)",
$apStatsMuCounts
);
}
$wlanstats = snmpwalk_cache_oid($this->getDeviceArray(), 'wlanStatsAssociatedClients', [], 'HIPATH-WIRELESS-HWC-MIB');
$wlannames = $this->getCacheByIndex('wlanName', 'HIPATH-WIRELESS-HWC-MIB');
foreach ($wlanstats as $index => $entry) {
$name = $wlannames[$index];
$sensors[] = new WirelessSensor(
'clients',
$this->getDeviceId(),
'1.3.6.1.4.1.4329.15.3.3.4.5.1.2.' . $index,
'ewc',
$name,
"SSID: $name"
);
}
return $sensors;
}
/**
* Discover wireless bit errors. This is in total bits. Type is errors.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessErrors()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'apPerfRadioPktRetx', [], 'HIPATH-WIRELESS-HWC-MIB');
$ap_interfaces = $this->getCacheByIndex('apName', 'HIPATH-WIRELESS-HWC-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[explode('.', $index)[0]];
$sensors[] = new WirelessSensor(
'errors',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.5.1.18.' . $index,
'ewc',
$index . 'Retx',
2020-09-21 15:59:34 +02:00
"Retransmits ($name radio " . explode('.', $index)[1] . ')'
);
}
return $sensors;
}
/**
* Discover wireless frequency. This is in MHz. Type is frequency.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessFrequency()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'apRadioStatusChannel', [], 'HIPATH-WIRELESS-HWC-MIB');
$ap_interfaces = $this->getCacheByIndex('ifName', 'IF-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[$index];
$sensors[] = new WirelessSensor(
'frequency',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.4.1.1.' . $index,
'ewc',
$index,
"Frequency ($name)"
);
}
return $sensors;
}
/**
* Discover wireless noise floor. This is in dBm. Type is noise-floor.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessNoiseFloor()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'dot11ExtRadioMaxNfCount', [], 'HIPATH-WIRELESS-DOT11-EXTNS-MIB');
$ap_interfaces = $this->getCacheByIndex('ifName', 'IF-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[$index];
$noisefloor = $entry['dot11ExtRadioMaxNfCount'];
$sensors[] = new WirelessSensor(
'noise-floor',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.1.4.3.1.32.' . $index,
'ewc',
$index,
"Noise floor ($name)",
$noisefloor,
1,
1,
'sum',
null,
-75
);
}
return $sensors;
}
/**
* Discover wireless RSSI (Received Signal Strength Indicator). This is in dBm. Type is rssi
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessRssi()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'apPerfRadioCurrentRSS', [], 'HIPATH-WIRELESS-HWC-MIB');
$ap_interfaces = $this->getCacheByIndex('apName', 'HIPATH-WIRELESS-HWC-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[explode('.', $index)[0]];
$sensors[] = new WirelessSensor(
'rssi',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.5.1.9.' . $index,
'ewc',
$index,
2020-09-21 15:59:34 +02:00
"RSS ($name radio " . explode('.', $index)[1] . ')'
);
}
return $sensors;
}
/**
* Discover wireless SNR. This is in dB. Type is snr.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessSnr()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'apPerfRadioCurrentSNR', [], 'HIPATH-WIRELESS-HWC-MIB');
$ap_interfaces = $this->getCacheByIndex('apName', 'HIPATH-WIRELESS-HWC-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[explode('.', $index)[0]];
$sensors[] = new WirelessSensor(
'snr',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.5.1.13.' . $index,
'ewc',
$index,
2020-09-21 15:59:34 +02:00
"SNR ($name radio " . explode('.', $index)[1] . ')'
);
}
return $sensors;
}
/**
* Discover wireless utilization. This is in %. Type is utilization.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessUtilization()
{
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'apPerfRadioCurrentChannelUtilization', [], 'HIPATH-WIRELESS-HWC-MIB');
$ap_interfaces = $this->getCacheByIndex('apName', 'HIPATH-WIRELESS-HWC-MIB');
$sensors = [];
foreach ($oids as $index => $entry) {
$name = $ap_interfaces[explode('.', $index)[0]];
$sensors[] = new WirelessSensor(
'utilization',
$this->getDeviceId(),
'.1.3.6.1.4.1.4329.15.3.5.2.5.1.5.' . $index,
'ewc',
$index,
2020-09-21 15:59:34 +02:00
"Utilization ($name radio " . explode('.', $index)[1] . ')'
);
}
return $sensors;
}
}