newdevice: Added connected AP count for Cisco WLCs (#6572)

* newdevice: Add connected AP count for Cisco WLCs
Adds ap-count wireless sensor type
fixes: #4295

* better detection
Update the overview graph to the new one
This commit is contained in:
Tony Murray
2017-05-04 02:03:10 -05:00
committed by Neil Lathwood
parent 1187d92351
commit 5ca07e11aa
7 changed files with 138 additions and 2 deletions

View File

@@ -127,6 +127,12 @@ class WirelessSensor extends Sensor
// Add new types here
// FIXME I'm really bad with icons, someone please help!
static $types = array(
'ap-count' => array(
'short' => 'APs',
'long' => 'AP Count',
'unit' => '',
'icon' => 'wifi',
),
'clients' => array(
'short' => 'Clients',
'long' => 'Client Count',

View File

@@ -0,0 +1,37 @@
<?php
/**
* WirelessApsDiscovery.php
*
* Discover Wireless AP Count Sensors
*
* 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 <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Interfaces\Discovery\Sensors;
interface WirelessApCountDiscovery
{
/**
* Discover wireless capacity. This is a percent. Type is capacity.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessApCount();
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* WirelessApsPolling.php
*
*Custom polling interface for wireless AP count
*
* 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 <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Interfaces\Polling\Sensors;
interface WirelessApCountPolling
{
/**
* Poll wireless AP count
* The returned array should be sensor_id => value pairs
*
* @param array $sensors Array of sensors needed to be polled
* @return array of polled data
*/
public function pollWirelessApCount(array $sensors);
}

View File

@@ -26,10 +26,11 @@
namespace LibreNMS\OS;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
use LibreNMS\OS;
class Ciscowlc extends OS implements WirelessClientsDiscovery
class Ciscowlc extends OS implements WirelessClientsDiscovery, WirelessApCountDiscovery
{
/**
* Discover wireless client counts. Type is clients.
@@ -75,4 +76,41 @@ class Ciscowlc extends OS implements WirelessClientsDiscovery
return $sensors;
}
/**
* Discover wireless capacity. This is a percent. Type is capacity.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessApCount()
{
$oids = array(
'CISCO-LWAPP-SYS-MIB::clsSysApConnectCount.0',
'AIRESPACE-SWITCHING-MIB::agentInventoryMaxNumberOfAPsSupported.0',
);
$data = snmp_get_multi($this->getDevice(), $oids);
if (isset($data[0]['clsSysApConnectCount'])) {
return array(
new WirelessSensor(
'ap-count',
$this->getDeviceId(),
'.1.3.6.1.4.1.9.9.618.1.8.4.0',
'ciscowlc',
0,
'Connected APs',
$data[0]['clsSysApConnectCount'],
1,
1,
'sum',
null,
$data[0]['agentInventoryMaxNumberOfAPsSupported'],
0
),
);
}
return array();
}
}

View File

@@ -0,0 +1,9 @@
<?php
$scale_min = '0';
$class = 'ap-count';
$unit = '';
$unit_long = 'APs';
require 'includes/graphs/device/wireless-sensor.inc.php';

View File

@@ -0,0 +1,8 @@
<?php
$scale_min = '0';
$unit_long = 'APs';
$unit = '';
include 'wireless-sensor.inc.php';

View File

@@ -6,7 +6,7 @@ over:
- { graph: device_bits, text: 'Device Traffic' }
- { graph: device_processor, text: 'CPU Usage' }
- { graph: device_mempool, text: 'Memory Usage' }
- { graph: device_ciscowlc_numaps, text: 'Number of APs' }
- { graph: device_wireless_ap-count, text: 'Connected APs' }
- { graph: device_wireless_clients, text: 'Number of Clients' }
icon: cisco
poller_modules: