From e2542a67d0952a318cfa180222e15830af692ab5 Mon Sep 17 00:00:00 2001 From: Justin Settle Date: Tue, 1 Nov 2016 10:57:38 -0400 Subject: [PATCH] Update wifi clients polling to support more than 2 radios --- includes/polling/wifi.inc.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/includes/polling/wifi.inc.php b/includes/polling/wifi.inc.php index c9c2b743f8..80234d966f 100644 --- a/includes/polling/wifi.inc.php +++ b/includes/polling/wifi.inc.php @@ -64,8 +64,8 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty } elseif ($device['os'] == 'unifi') { echo 'Checking Unifi Wireless clients... '; - $clients = snmp_walk($device, '.1.3.6.1.4.1.41112.1.6.1.2.1.8', '-Oqv'); - $bands = snmp_walk($device, '.1.3.6.1.4.1.41112.1.6.1.2.1.9', '-Oqv'); + $clients = snmp_walk($device, 'unifiVapNumStations', '-Oqv', 'UBNT-UniFi-MIB'); + $bands = snmp_walk($device, 'unifiVapRadio', '-Oqv', 'UBNT-UniFi-MIB'); $clients = explode("\n", $clients); $bands = explode("\n", $bands); foreach ($bands as $index => $band_index) { @@ -80,27 +80,19 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty include 'includes/polling/mib/ubnt-unifi-mib.inc.php'; } - if (is_numeric($wificlients1)) { + // Loop through all $wificlients# and data_update() + $i = 1; + while (is_numeric(${'wificlients'.$i})) { $tags = array( 'rrd_def' => 'DS:wificlients:GAUGE:600:-273:1000', - 'rrd_name' => array('wificlients', 'radio1'), - 'radio' => 1, + 'rrd_name' => array('wificlients', "radio$i"), + 'radio' => $i, ); - data_update($device, 'wificlients', $tags, $wificlients1); + data_update($device, 'wificlients', $tags, ${'wificlients'.$i}); $graphs['wifi_clients'] = true; + unset(${'wificlients'.$i}); + $i++; } - - if (is_numeric($wificlients2)) { - $tags = array( - 'rrd_def' => 'DS:wificlients:GAUGE:600:-273:1000', - 'rrd_name' => array('wificlients', 'radio2'), - 'radio' => 2, - ); - data_update($device, 'wificlients', $tags, $wificlients2); - $graphs['wifi_clients'] = true; - } - - unset($wificlients2, $wificlients1); }//end if echo "\n";