From 49a613a44dac44b87c7136fb94eb088f14877b19 Mon Sep 17 00:00:00 2001 From: Frederik Mogensen Date: Sun, 4 Oct 2015 23:01:24 +0200 Subject: [PATCH 1/4] Added memory to CiscoWLC, added discovery of APs to CiscoWLC, Fixed wrong table used in accesspoint-tab --- includes/discovery/mempools/ciscowlc.inc.php | 12 ++ includes/polling/mempools/ciscowlc.inc.php | 12 ++ includes/polling/os/ciscowlc.inc.php | 135 ++++++++++++++++--- 3 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 includes/discovery/mempools/ciscowlc.inc.php create mode 100644 includes/polling/mempools/ciscowlc.inc.php diff --git a/includes/discovery/mempools/ciscowlc.inc.php b/includes/discovery/mempools/ciscowlc.inc.php new file mode 100644 index 0000000000..b966bdfff2 --- /dev/null +++ b/includes/discovery/mempools/ciscowlc.inc.php @@ -0,0 +1,12 @@ + $value) { + + $indexName = substr($key, 0, -2); + + $channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber']); + $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); + $name = $stats[$indexName]['bsnAPName']; + $numasoclients = $value['bsnApIfNoOfUsers']; + $radionum = array_pop(explode('.',$key)); + $txpow = $value['bsnAPIfPhyTxPowerLevel']; + $type = $value['bsnAPIfType']; + $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; + + // TODO + + $numactbssid = 0; + $nummonbssid = 0; + $nummonclients = 0; + $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; + + d_echo(" name: $name\n"); + d_echo(" radionum: $radionum\n"); + d_echo(" type: $type\n"); + d_echo(" channel: $channel\n"); + d_echo(" txpow: $txpow\n"); + d_echo(" radioutil: $radioutil\n"); + d_echo(" numasoclients: $numasoclients\n"); + d_echo(" interference: $interference\n"); + + // if there is a numeric channel, assume the rest of the data is valid, I guess + if (is_numeric($channel)) { + $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$name.$radionum.rrd"); + if (!is_file($rrd_file)) { + $dslist = 'DS:channel:GAUGE:600:0:200 '; + $dslist .= 'DS:txpow:GAUGE:600:0:200 '; + $dslist .= 'DS:radioutil:GAUGE:600:0:100 '; + $dslist .= 'DS:nummonclients:GAUGE:600:0:500 '; + $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 '; + $dslist .= 'DS:numasoclients:GAUGE:600:0:500 '; + $dslist .= 'DS:interference:GAUGE:600:0:2000 '; + rrdtool_create($rrd_file, "--step 300 $dslist ".$config['rrd_rra']); + } + + $fields = array( + 'channel' => $channel, + 'txpow' => $txpow, + 'radioutil' => $radioutil, + 'nummonclients' => $nummonclients, + 'nummonbssid' => $nummonbssid, + 'numasoclients' => $numasoclients, + 'interference' => $interference, + ); + + rrdtool_update($rrd_file, $fields); + + } + + $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, + 'type' => $type, + 'deleted' => 0, + 'channel' => $channel, + 'txpow' => $txpow, + 'radioutil' => $radioutil, + 'numasoclients' => $numasoclients, + 'nummonclients' => $nummonclients, + 'numactbssid' => $numactbssid, + 'nummonbssid' => $nummonbssid, + 'interference' => $interference + ), + 'access_points', + '`accesspoint_id` = ?', array($foundid)); + } +}//end foreach + +for ($z = 0; $z < sizeof($ap_db); $z++) { + if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { + dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id'])); + } +} From e2c30f382360f25b70148a993a185354759aa46a Mon Sep 17 00:00:00 2001 From: Frederik Mogensen Date: Fri, 24 Jun 2016 22:21:16 +0200 Subject: [PATCH 2/4] Cleaning up --- includes/polling/os/ciscowlc.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/polling/os/ciscowlc.inc.php b/includes/polling/os/ciscowlc.inc.php index 893db6738c..34fad70e96 100644 --- a/includes/polling/os/ciscowlc.inc.php +++ b/includes/polling/os/ciscowlc.inc.php @@ -85,13 +85,12 @@ foreach ($radios as $key => $value) { $txpow = $value['bsnAPIfPhyTxPowerLevel']; $type = $value['bsnAPIfType']; $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; + $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; // TODO - $numactbssid = 0; $nummonbssid = 0; $nummonclients = 0; - $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; d_echo(" name: $name\n"); d_echo(" radionum: $radionum\n"); From e29a6002a8539bb1725392d00ad4b5dc00fffa45 Mon Sep 17 00:00:00 2001 From: Frederik Mogensen Date: Sun, 26 Jun 2016 12:10:21 +0200 Subject: [PATCH 3/4] Fixed problem where 'ghost' APs would appear --- includes/polling/os/ciscowlc.inc.php | 199 ++++++++++++++------------- 1 file changed, 100 insertions(+), 99 deletions(-) diff --git a/includes/polling/os/ciscowlc.inc.php b/includes/polling/os/ciscowlc.inc.php index 34fad70e96..2d434bf6c3 100644 --- a/includes/polling/os/ciscowlc.inc.php +++ b/includes/polling/os/ciscowlc.inc.php @@ -42,17 +42,17 @@ $numAccessPoints = count($stats); $numClients = 0; foreach ($APstats as $key => $value) { - $numClients += $value['bsnApIfNoOfUsers']; + $numClients += $value['bsnApIfNoOfUsers']; } $rrdfile = $host_rrd.'/ciscowlc'.safename('.rrd'); if (!is_file($rrdfile)) { - rrdtool_create($rrdfile, ' --step 300 DS:NUMAPS:GAUGE:600:0:12500000000 DS:NUMCLIENTS:GAUGE:600:0:12500000000 '.$config['rrd_rra']); + rrdtool_create($rrdfile, ' --step 300 DS:NUMAPS:GAUGE:600:0:12500000000 DS:NUMCLIENTS:GAUGE:600:0:12500000000 '.$config['rrd_rra']); } $fields = array( - 'NUMAPS' => $numAccessPoints, - 'NUMCLIENTS' => $numClients + 'NUMAPS' => $numAccessPoints, + 'NUMCLIENTS' => $numClients ); $ret = rrdtool_update($rrdfile, $fields); @@ -64,7 +64,7 @@ if (!is_file($wificlientsrrd)) { } $fields = array( - 'wificlients' => $numClients + 'wificlients' => $numClients ); rrdtool_update($wificlientsrrd, $fields); @@ -74,111 +74,112 @@ $graphs['wifi_clients'] = true; $ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', array($device['device_id'])); foreach ($radios as $key => $value) { + + $indexName = substr($key, 0, -2); - $indexName = substr($key, 0, -2); + $channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber']); + $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); + $name = $stats[$indexName]['bsnAPName']; + $numasoclients = $value['bsnApIfNoOfUsers']; + $radionum = array_pop(explode('.',$key)); + $txpow = $value['bsnAPIfPhyTxPowerLevel']; + $type = $value['bsnAPIfType']; + $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; + $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; - $channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber']); - $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); - $name = $stats[$indexName]['bsnAPName']; - $numasoclients = $value['bsnApIfNoOfUsers']; - $radionum = array_pop(explode('.',$key)); - $txpow = $value['bsnAPIfPhyTxPowerLevel']; - $type = $value['bsnAPIfType']; - $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; - $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; + // TODO + $numactbssid = 0; + $nummonbssid = 0; + $nummonclients = 0; - // TODO - $numactbssid = 0; - $nummonbssid = 0; - $nummonclients = 0; + d_echo(" name: $name\n"); + d_echo(" radionum: $radionum\n"); + d_echo(" type: $type\n"); + d_echo(" channel: $channel\n"); + d_echo(" txpow: $txpow\n"); + d_echo(" radioutil: $radioutil\n"); + d_echo(" numasoclients: $numasoclients\n"); + d_echo(" interference: $interference\n"); - d_echo(" name: $name\n"); - d_echo(" radionum: $radionum\n"); - d_echo(" type: $type\n"); - d_echo(" channel: $channel\n"); - d_echo(" txpow: $txpow\n"); - d_echo(" radioutil: $radioutil\n"); - d_echo(" numasoclients: $numasoclients\n"); - d_echo(" interference: $interference\n"); + // if there is a numeric channel, assume the rest of the data is valid, I guess + if (!is_numeric($channel)) { + continue; + } - // if there is a numeric channel, assume the rest of the data is valid, I guess - if (is_numeric($channel)) { - $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$name.$radionum.rrd"); - if (!is_file($rrd_file)) { - $dslist = 'DS:channel:GAUGE:600:0:200 '; - $dslist .= 'DS:txpow:GAUGE:600:0:200 '; - $dslist .= 'DS:radioutil:GAUGE:600:0:100 '; - $dslist .= 'DS:nummonclients:GAUGE:600:0:500 '; - $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 '; - $dslist .= 'DS:numasoclients:GAUGE:600:0:500 '; - $dslist .= 'DS:interference:GAUGE:600:0:2000 '; - rrdtool_create($rrd_file, "--step 300 $dslist ".$config['rrd_rra']); - } + $rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$name.$radionum.rrd"); + if (!is_file($rrd_file)) { + $dslist = 'DS:channel:GAUGE:600:0:200 '; + $dslist .= 'DS:txpow:GAUGE:600:0:200 '; + $dslist .= 'DS:radioutil:GAUGE:600:0:100 '; + $dslist .= 'DS:nummonclients:GAUGE:600:0:500 '; + $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 '; + $dslist .= 'DS:numasoclients:GAUGE:600:0:500 '; + $dslist .= 'DS:interference:GAUGE:600:0:2000 '; + rrdtool_create($rrd_file, "--step 300 $dslist ".$config['rrd_rra']); + } - $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, + ); - rrdtool_update($rrd_file, $fields); + rrdtool_update($rrd_file, $fields); + $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; } + } - $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, - 'type' => $type, - '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( + '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, + 'type' => $type, + 'deleted' => 0, + 'channel' => $channel, + 'txpow' => $txpow, + 'radioutil' => $radioutil, + 'numasoclients' => $numasoclients, + 'nummonclients' => $nummonclients, + 'numactbssid' => $numactbssid, + 'nummonbssid' => $nummonbssid, + 'interference' => $interference + ), + 'access_points', + '`accesspoint_id` = ?', array($foundid)); + } }//end foreach for ($z = 0; $z < sizeof($ap_db); $z++) { - if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { - dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id'])); - } + if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { + dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id'])); + } } From c19080d0f60da5d70da6827a7cfc72dc9d1c4962 Mon Sep 17 00:00:00 2001 From: Frederik Mogensen Date: Sat, 2 Jul 2016 20:49:59 +0200 Subject: [PATCH 4/4] Passing a reference to array_pop --- includes/polling/os/ciscowlc.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/polling/os/ciscowlc.inc.php b/includes/polling/os/ciscowlc.inc.php index 2d434bf6c3..ab0cc14570 100644 --- a/includes/polling/os/ciscowlc.inc.php +++ b/includes/polling/os/ciscowlc.inc.php @@ -81,7 +81,8 @@ foreach ($radios as $key => $value) { $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); $name = $stats[$indexName]['bsnAPName']; $numasoclients = $value['bsnApIfNoOfUsers']; - $radionum = array_pop(explode('.',$key)); + $radioArray = explode('.',$key); + $radionum = array_pop($radioArray); $txpow = $value['bsnAPIfPhyTxPowerLevel']; $type = $value['bsnAPIfType']; $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower'];