From adaf08b1bf9e36fafec1af34e62009b7e1c66522 Mon Sep 17 00:00:00 2001 From: Timothy Willey Date: Sun, 7 Apr 2019 06:26:55 -0700 Subject: [PATCH] fix aruba-controller polling (#10071) --- includes/polling/aruba-controller.inc.php | 196 +++++++++++++--------- 1 file changed, 118 insertions(+), 78 deletions(-) diff --git a/includes/polling/aruba-controller.inc.php b/includes/polling/aruba-controller.inc.php index 98295e3daf..8f23efd744 100644 --- a/includes/polling/aruba-controller.inc.php +++ b/includes/polling/aruba-controller.inc.php @@ -40,12 +40,12 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { foreach ($switch_apinfo_oids as $oid) { echo "$oid "; - $aruba_apstats = snmpwalk_cache_oid_num($device, $oid, $aruba_apstats, 'WLSX-WLAN-MIB'); + $aruba_apstats = snmpwalk_cache_numerical_oid($device, $oid, $aruba_apstats, 'WLSX-WLAN-MIB'); } foreach ($switch_apname_oids as $oid) { echo "$oid "; - $aruba_apnames = snmpwalk_cache_oid_num($device, $oid, $aruba_apnames, 'WLSX-WLAN-MIB'); + $aruba_apnames = snmpwalk_cache_numerical_oid($device, $oid, $aruba_apnames, 'WLSX-WLAN-MIB'); } @@ -68,93 +68,133 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { $ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', array($device['device_id'])); - foreach ($aruba_apnames as $key => $value) { - $radioid = str_replace('1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.16.', '', $key); - $name = $value['']; - $type = $aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.2.$radioid"]['']; - $channel = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.3.$radioid"][''] + 0); - $txpow = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.4.$radioid"][''] + 0); - $radioutil = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.6.$radioid"][''] + 0); - $numasoclients = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.7.$radioid"][''] + 0); - $nummonclients = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.8.$radioid"][''] + 0); - $numactbssid = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.9.$radioid"][''] + 0); - $nummonbssid = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.10.$radioid"][''] + 0); - $interference = ($aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.$radioid"][''] + 0); + foreach ($aruba_apnames as $key1 => $value1) { + foreach ($value1 as $key => $value) { + $radioid = str_replace('.1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.16.', '', $key); + $name = $value; + $type = $aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.2.$radioid"]; + $channel = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.3.$radioid"] + 0); + $txpow = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.4.$radioid"] + 0); + $radioutil = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.6.$radioid"] + 0); + $numasoclients = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.7.$radioid"] + 0); + $nummonclients = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.8.$radioid"] + 0); + $numactbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.9.$radioid"] + 0); + $nummonbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.10.$radioid"] + 0); + $interference = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.$radioid"] + 0); - $radionum = substr($radioid, (strlen($radioid) - 1), 1); + $radionum = substr($radioid, (strlen($radioid) - 1), 1); - if ($debug) { - echo "* radioid: $radioid\n"; - echo " radionum: $radionum\n"; - echo " name: $name\n"; - echo " type: $type\n"; - echo " channel: $channel\n"; - echo " txpow: $txpow\n"; - echo " radioutil: $radioutil\n"; - echo " numasoclients: $numasoclients\n"; - echo " interference: $interference\n"; - } + d_echo($key.PHP_EOL); + d_echo($value.PHP_EOL); + d_echo('* radioid: '.$radioid.PHP_EOL); + d_echo(' radionum: '.$radionum.PHP_EOL); + d_echo(' name: '.$name.PHP_EOL); + d_echo(' type: '.$type.PHP_EOL); + d_echo(' channel: '.$channel.PHP_EOL); + d_echo(' txpow: '.$txpow.PHP_EOL); + d_echo(' radioutil: '.$radioutil.PHP_EOL); + d_echo(' numasoclients: '.$numasoclients.PHP_EOL); + d_echo(' interference: '.$interference.PHP_EOL); + d_echo(PHP_EOL); - // if there is a numeric channel, assume the rest of the data is valid, I guess - if (is_numeric($channel)) { - $rrd_name = array('arubaap', $name.$radionum); + // if there is a numeric channel, assume the rest of the data is valid, I guess + if (is_numeric($channel)) { + $rrd_name = array('arubaap', $name.$radionum); - $rrd_def = RrdDefinition::make() - ->addDataset('channel', 'GAUGE', 0, 200) - ->addDataset('txpow', 'GAUGE', 0, 200) - ->addDataset('radioutil', 'GAUGE', 0, 100) - ->addDataset('nummonclients', 'GAUGE', 0, 500) - ->addDataset('nummonbssid', 'GAUGE', 0, 200) - ->addDataset('numasoclients', 'GAUGE', 0, 500) - ->addDataset('interference', 'GAUGE', 0, 2000); + $rrd_def = RrdDefinition::make() + ->addDataset('channel', 'GAUGE', 0, 200) + ->addDataset('txpow', 'GAUGE', 0, 200) + ->addDataset('radioutil', 'GAUGE', 0, 100) + ->addDataset('nummonclients', 'GAUGE', 0, 500) + ->addDataset('nummonbssid', 'GAUGE', 0, 200) + ->addDataset('numasoclients', 'GAUGE', 0, 500) + ->addDataset('interference', 'GAUGE', 0, 2000); - $fields = array( - 'channel' => $channel, - 'txpow' => $txpow, - 'radioutil' => $radioutil, - 'nummonclients' => $nummonclients, - 'nummonbssid' => $nummonbssid, - 'numasoclients' => $numasoclients, - 'interference' => $interference, - ); + $fields = array( + 'channel' => $channel, + 'txpow' => $txpow, + 'radioutil' => $radioutil, + 'nummonclients' => $nummonclients, + 'nummonbssid' => $nummonbssid, + 'numasoclients' => $numasoclients, + 'interference' => $interference, + ); - $tags = array( - 'name' => $name, - 'radionum' => $radionum, - 'rrd_name' => $rrd_name, - 'rrd_def' => $rrd_def - ); + $tags = array( + 'name' => $name, + 'radionum' => $radionum, + 'rrd_name' => $rrd_name, + 'rrd_def' => $rrd_def + ); - data_update($device, 'aruba', $tags, $fields); - } - - // generate the mac address - $macparts = explode('.', $radioid, -1); - $mac = ''; - foreach ($macparts as $part) { - $mac .= sprintf('%02x', $part).':'; - } - - $mac = rtrim($mac, ':'); - - - $foundid = 0; - - for ($z = 0; $z < sizeof($ap_db); $z++) { - if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) { - $foundid = $ap_db[$z]['accesspoint_id']; - $ap_db[$z]['seen'] = 1; - continue; + data_update($device, 'aruba', $tags, $fields); + } + + // generate the mac address + $macparts = explode('.', $radioid, -1); + $mac = ''; + foreach ($macparts as $part) { + $mac .= sprintf('%02x', $part).':'; + } + + $mac = rtrim($mac, ':'); + + + $foundid = 0; + + for ($z = 0; $z < sizeof($ap_db); $z++) { + if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) { + $foundid = $ap_db[$z]['accesspoint_id']; + $ap_db[$z]['seen'] = 1; + continue; + } } - } - if ($foundid == 0) { - $ap_id = dbInsert(array('device_id' => $device['device_id'], 'name' => $name, 'radio_number' => $radionum, 'type' => $type, 'mac_addr' => $mac, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points'); - } else { - dbUpdate(array('mac_addr' => $mac, 'deleted' => 0, 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'numasoclients' => $numasoclients, 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, 'interference' => $interference), 'access_points', '`accesspoint_id` = ?', array($foundid)); - } + if ($foundid == 0) { + $ap_id = dbInsert( + array( + 'channel' => $channel, + 'deleted' => 0, + 'device_id' => $device['device_id'], + 'interference' => $interference, + 'mac_addr' => $mac, + 'name' => $name, + 'numactbssid' => $numactbssid, + 'numasoclients' => $numasoclients, + 'nummonbssid' => $nummonbssid, + 'nummonclients' => $nummonclients, + 'radio_number' => $radionum, + 'radioutil' => $radioutil, + 'txpow' => $txpow, + 'type' => $type + ), + 'access_points' + ); + } else { + dbUpdate( + array( + 'channel' => $channel, + 'deleted' => 0, + 'interference' => $interference, + 'mac_addr' => $mac, + 'name' => $name, + 'numactbssid' => $numactbssid, + 'numasoclients' => $numasoclients, + 'nummonbssid' => $nummonbssid, + 'nummonclients' => $nummonclients, + 'radio_number' => $radionum, + 'radioutil' => $radioutil, + 'txpow' => $txpow, + 'type' => $type + ), + 'access_points', + '`accesspoint_id` = ?', + array($foundid) + ); + } + }//end foreach }//end foreach // mark APs which are not on this controller anymore as deleted