Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW OS Aruba Instant #9954

Merged
merged 37 commits into from May 13, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b6dd23d
New OS: Aruba Instant
twilley Mar 19, 2019
c5b4439
New OS: Aruba Instant
twilley Mar 19, 2019
ad1b82c
recreate test data
twilley Mar 20, 2019
5bacb60
remove aruba_instant test data
twilley Mar 20, 2019
8367818
remove empty file includes/definitions/discovery/aruba-instant.yaml
twilley Mar 20, 2019
587e590
fix state sensor discovery
twilley Mar 21, 2019
c46bc30
remove minor changes to includes/polling/functions.inc.phpwq
twilley Mar 23, 2019
099529e
move mac helper functions to Rewrite class
twilley Mar 23, 2019
68b3d30
simplify snmpwalk_group usage, general code cleanup
twilley Mar 24, 2019
2de46cb
fixes
twilley Mar 24, 2019
d48de84
fixes
twilley Mar 24, 2019
8ada780
fixes
twilley Mar 24, 2019
af51e52
fixes
twilley Mar 24, 2019
970ec29
fixes
twilley Mar 24, 2019
4f4325e
fixes
twilley Mar 24, 2019
c36375c
recreate test data for 105 variant
twilley Mar 24, 2019
e6fd438
Merge branch 'master' of github.com:librenms/librenms into newos-arub…
twilley Apr 30, 2019
8058acc
Add Client sensors for 8.4.0.0+
twilley Apr 30, 2019
68a46c3
Merge branch 'master' of github.com:librenms/librenms into newos-arub…
twilley Apr 30, 2019
c765155
begin stream-lining discovery and polling. separating discovery funct…
twilley Apr 30, 2019
a805695
update test data
twilley Apr 30, 2019
7625df4
update test data
twilley Apr 30, 2019
2892d4b
update test data
twilley Apr 30, 2019
c24eca9
improve mempool discovery/polling, clean up os polling, improve state…
twilley Apr 30, 2019
a601196
Merge branch 'master' of github.com:librenms/librenms into newos-arub…
twilley Apr 30, 2019
9f9be83
attempt to implement custom AP and client discovery and polling
twilley Apr 30, 2019
a51f012
code fixes
twilley Apr 30, 2019
43a2203
re-add ap count top graph
twilley Apr 30, 2019
cf9c80c
more fixes
twilley May 1, 2019
37ca2dd
more fixes
twilley May 1, 2019
d8dea82
more fixes
twilley May 1, 2019
b667d31
more fixes
twilley May 1, 2019
974cbeb
remove some debugging, update test data
twilley May 1, 2019
f230592
code cleanup
twilley May 1, 2019
020b2c4
code cleanup
twilley May 1, 2019
6a4b95c
address some scrutinizer warnings
twilley May 1, 2019
12fa942
Merge branch 'master' of github.com:librenms/librenms into newos-arub…
twilley May 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
189 changes: 189 additions & 0 deletions LibreNMS/OS/ArubaInstant.php
@@ -0,0 +1,189 @@
<?php
/**
* ArubaInstant.php
*
* HPE Aruba Instant
*
*
* 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 2019 Timothy Willey
* @author Timothy Willey <developer@timothywilley.net>
*/

namespace LibreNMS\OS;

use LibreNMS\Device\Processor;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessFrequencyDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessNoiseFloorDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessPowerDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessUtilizationDiscovery;
use LibreNMS\Interfaces\Polling\Sensors\WirelessFrequencyPolling;
use LibreNMS\OS;
use LibreNMS\Util\Rewrite;

class ArubaInstant extends OS implements
ProcessorDiscovery,
WirelessClientsDiscovery,
WirelessFrequencyDiscovery,
WirelessFrequencyPolling,
WirelessNoiseFloorDiscovery,
WirelessPowerDiscovery,
WirelessUtilizationDiscovery
{
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
// instant
return $this->discoverInstantCPU('aiAPCPUUtilization');
}


/**
* Aruba Instant CPU Discovery
*
* @return array Sensors
*/
private function discoverInstantCPU($mib)
{
$ai_mib = 'AI-AP-MIB';
$ai_sg_data = $this->getCacheTable('aiStateGroup', $ai_mib);
$processors = [];
foreach ($ai_sg_data as $ai_ap => $ai_ap_oid) {
$value = $ai_ap_oid[$mib];
$combined_oid = sprintf('%s::%s.%s', $ai_mib, $mib, Rewrite::oidMac($ai_ap));
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On', null);
$description = $ai_sg_data[$ai_ap]['aiAPSerialNum'];
$processors[] = Processor::discover('aruba-instant', $this->getDeviceId(), $oid, Rewrite::macToHex($ai_ap), $description, 1, $value);
d_echo('Processor Array:'.PHP_EOL);
d_echo($processors);
}
return $processors;
}


/**
* Discover wireless client counts. Type is clients.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array Sensors
*/
public function discoverWirelessClients()
{
return $this->discoverInstantRadio('clients', 'aiRadioClientNum');
}

/**
* 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()
{
// instant
return $this->discoverInstantRadio('frequency', 'aiRadioChannel');
}

/**
* Discover wireless noise floor. This is in dBm/Hz. Type is noise-floor.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array
*/
public function discoverWirelessNoiseFloor()
{
// instant
return $this->discoverInstantRadio('noise-floor', 'aiRadioNoiseFloor');
}

/**
* Discover wireless tx or rx power. This is in dBm. Type is power.
* Returns an array of LibreNMS\Device\Sensor objects that have been discovered
*
* @return array
*/
public function discoverWirelessPower()
{
// instant
return $this->discoverInstantRadio('power', 'aiRadioTransmitPower', "%s Radio %s: Tx Power");
}

/**
* 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()
{
// instant
return $this->discoverInstantRadio('utilization', 'aiRadioUtilization64');
}

/**
* Aruba Instant Radio Discovery
*
* @return array Sensors
*/
private function discoverInstantRadio($type, $mib, $desc = '%s Radio %s')
{
$ai_mib = 'AI-AP-MIB';
$ai_sg_data = $this->getCacheTable('aiStateGroup', $ai_mib);

$sensors = [];
foreach ($ai_sg_data as $ai_ap => $ai_ap_oid) {
if (isset($ai_ap_oid[$mib])) {
foreach ($ai_ap_oid[$mib] as $ai_ap_radio => $value) {
if ($type == 'frequency') {
$value = WirelessSensor::channelToFrequency($this->decodeChannel($value));
}
$combined_oid = sprintf('%s::%s.%s.%s', $ai_mib, $mib, Rewrite::oidMac($ai_ap), $ai_ap_radio);
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On', null);
$description = sprintf($desc, $ai_sg_data[$ai_ap]['aiAPSerialNum'], $ai_ap_radio);
$index = sprintf('%s.%s', Rewrite::macToHex($ai_ap), $ai_ap_radio);
$sensors[] = new WirelessSensor($type, $this->getDeviceId(), $oid, 'aruba-instant', $index, $description, $value);
} // end foreach
} // end if
} // end foreach
return $sensors;
}

protected function decodeChannel($channel)
{
return $channel & 255; // mask off the channel width information
}

/**
* Poll wireless frequency as MHz
* 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 pollWirelessFrequency(array $sensors)
{
return $this->pollWirelessChannelAsFrequency($sensors, [$this, 'decodeChannel']);
}
}
40 changes: 40 additions & 0 deletions LibreNMS/Util/Rewrite.php
Expand Up @@ -122,6 +122,46 @@ public static function readableMac($mac)
return rtrim(chunk_split($mac, 2, ':'), ':');
}

/**
* Reformat hex MAC as oid MAC (dotted-decimal)
*
* 00:12:34:AB:CD:EF becomes 0.18.52.171.205.239
* 0:12:34:AB:CD:EF becomes 0.18.52.171.205.239
* 00:02:04:0B:0D:0F becomes 0.2.4.11.13.239
* 0:2:4:B:D:F becomes 0.2.4.11.13.15
*
* @param $mac
* @return string oid representation of a MAC address
*/
public static function oidMac($mac)
{
return implode('.', array_map('hexdec', explode(':', $mac)));
}

/**
* Reformat Hex MAC with delimiters to Hex String without delimiters
*
* Assumes the MAC address is well-formed and in a common format.
* 00:12:34:ab:cd:ef becomes 001234abcdef
* 00:12:34:AB:CD:EF becomes 001234ABCDEF
* 0:12:34:AB:CD:EF becomes 001234ABCDEF
* 00-12-34-AB-CD-EF becomes 001234ABCDEF
* 001234-ABCDEF becomes 001234ABCDEF
* 0012.34AB.CDEF becomes 001234ABCDEF
* 00:02:04:0B:0D:0F becomes 0002040B0D0F
* 0:2:4:B:D:F becomes 0002040B0D0F
*
* @param string hexadecimal MAC address with or without common delimiters
* @return string undelimited hexadecimal MAC address
*/
public static function macToHex($mac)
{
$mac_array = explode(':', str_replace(['-','.'], ':', $mac));
$mac_padding = array_fill(0, count($mac_array), 12/count($mac_array));

return implode(array_map('zeropad', $mac_array, $mac_padding));
}

/**
* Make Cisco hardware human readable
*
Expand Down
19 changes: 19 additions & 0 deletions html/includes/graphs/device/aruba-instant_numaps.inc.php
@@ -0,0 +1,19 @@
<?php

$rrd_filename = rrd_name($device['hostname'], 'aruba-instant');

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Number of APs';
$rrd_list[0]['ds'] = 'NUMAPS';

$unit_text = 'APs';
$units = '';
$total_units = '';
$colours = 'mixed';

$scale_min = '0';
$nototal = 1;

if ($rrd_list) {
include 'includes/graphs/generic_multi_line.inc.php';
}
21 changes: 21 additions & 0 deletions html/includes/graphs/device/aruba-instant_numclients.inc.php
@@ -0,0 +1,21 @@
<?php

$rrd_filename = rrd_name($device['hostname'], 'aruba-instant');

$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Clients';
$rrd_list[0]['ds'] = 'NUMCLIENTS';

$unit_text = 'Clients';

$units = '';
$total_units = '';
$colours = 'mixed';

$scale_min = '0';

$nototal = 1;

if ($rrd_list) {
include 'includes/graphs/generic_multi_line.inc.php';
}
13 changes: 13 additions & 0 deletions includes/definitions/aruba-instant.yaml
@@ -0,0 +1,13 @@
os: aruba-instant
text: 'Aruba Instant'
type: wireless
icon: aruba
mib_dir:
- arubaos
over:
- { graph: device_aruba-instant_numaps, text: 'Number of APs' }
- { graph: device_aruba-instant_numclients, text: 'Number of Clients' }
discovery:
-
sysObjectID: .1.3.6.1.4.1.14823.1.2. #Aruba apProducts (Aruba Instant)
sysDescr: ArubaOS
4 changes: 4 additions & 0 deletions includes/definitions/arubaos.yaml
Expand Up @@ -11,5 +11,9 @@ discovery:
- sysObjectID:
- .1.3.6.1.4.1.14823. #ArubaOS
- .1.3.6.1.4.1.6486.800.1.1.2.2.2. #AOS-W
sysObjectID_except:
- .1.3.6.1.4.1.14823.1.2 #Aruba apProducts (Aruba Instant)
- sysDescr:
- ArubaOS
sysObjectID_except:
- .1.3.6.1.4.1.14823.1.2 #Aruba apProducts (Aruba Instant)
48 changes: 48 additions & 0 deletions includes/discovery/entity-physical/entity-physical.inc.php
Expand Up @@ -6,6 +6,36 @@
$entity_array = array();
echo ' jnxBoxAnatomy';
$entity_array = snmpwalk_cache_oid($device, 'jnxBoxAnatomy', $entity_array, 'JUNIPER-MIB');
} elseif ($device['os'] == 'aruba-instant') {
$entity_array = array();
echo 'aruba-instant';

$ai_mib = 'AI-AP-MIB';
$ai_ig_data = snmpwalk_group($device, 'aiInfoGroup', $ai_mib);
discover_entity_physical(
$valid,
$device,
1, // entPhysicalIndex
$ai_ig_data['aiVirtualControllerIPAddress.0'], // entPhysicalDescr
'chassis', // entPhysicalClass
$ai_ig_data['aiVirtualControllerName.0'], // entPhysicalName
'Instant Virutal Controller Cluster', // entPhysicalModelName
$ai_ig_data['aiVirtualControllerKey.0'], // entPhysicalSerialNum
'0', // entPhysicalContainedIn
'Aruba', // entPhysicalMfgName
'-1', // entPhysicalParentRelPos
'Aruba', // entPhysicalVendorType
null, // entPhysicalHardwareRev
null, // entPhysicalFirmwareRev
null, // entPhysicalSoftwareRev
null, // entPhysicalIsFRU
null, // entPhysicalAlias
null, // entPhysicalAssetID
null // ifIndex
);

$entity_array = snmpwalk_group($device, 'aiAccessPointEntry', $ai_mib);
$instant_index = 2;
} elseif ($device['os'] == 'timos') {
$entity_array = array();
echo 'tmnxHwObjs';
Expand Down Expand Up @@ -108,6 +138,24 @@
// fix for issue 1865, $entPhysicalIndex, as it contains a quad dotted number on newer Junipers
// using str_replace to remove all dots should fix this even if it changes in future
$entPhysicalIndex = str_replace('.', '', $entPhysicalIndex);
} elseif ($device['os'] == 'aruba-instant') {
$entPhysicalDescr = $entry['aiAPMACAddress'];
$entPhysicalContainedIn = 1;
$entPhysicalSerialNum = $entry['aiAPSerialNum'];
$entPhysicalModelName = $entry['aiAPModel'];
$entPhysicalMfgName = 'Aruba';
$entPhysicalVendorType = 'Aruba';
$entPhysicalParentRelPos = -1;
$entPhysicalSoftwareRev = $device['version'];
$entPhysicalIndex = $instant_index;

if ($entry['aiAPIPAddress'] == $ai_ig_data['aiMasterIPAddress.0']) {
$entPhysicalName = sprintf('%s %s Cluster Master', $entry['aiAPName'], $entry['aiAPIPAddress']);
} else {
$entPhysicalName = sprintf('%s %s Cluster Member', $entry['aiAPName'], $entry['aiAPIPAddress']);
}

$instant_index += 1;
} elseif ($device['os'] == 'timos') {
$entPhysicalDescr = $entry['tmnxCardTypeDescription'];
$entPhysicalContainedIn = $entry['tmnxHwContainedIn'];
Expand Down