Issues (2963)

LibreNMS/OS/Ruckuswireless.php (1 issue)

1
<?php
2
3
namespace LibreNMS\OS;
4
5
use LibreNMS\Device\WirelessSensor;
6
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
7
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
8
use LibreNMS\OS;
9
10
class Ruckuswireless extends OS implements
11
    WirelessClientsDiscovery,
12
    WirelessApCountDiscovery
13
{
14
    public function discoverWirelessClients()
15
    {
16
17
// Find Per SSID Client Count
18
        $sensors = [];
19
        $ssids = $this->getCacheByIndex('ruckusZDWLANSSID', 'RUCKUS-ZD-WLAN-MIB');
20
        $counts = $this->getCacheByIndex('ruckusZDWLANNumSta', 'RUCKUS-ZD-WLAN-MIB');
21
22
        $total_oids = [];
23
        $total = 0;
24
        $index = null;
25
        foreach ($counts as $index => $count) {
26
            $oid = '.1.3.6.1.4.1.25053.1.2.2.1.1.1.1.1.12.' . $index;
27
            $total_oids[] = $oid;
28
            $total += $count;
29
30
            $sensors[] = new WirelessSensor(
31
                'clients',
32
                $this->getDeviceId(),
33
                $oid,
34
                'ruckuswireless',
35
                $index,
36
                'SSID: ' . $ssids[$index],
37
                $count
38
            );
39
        }
40
41
        // Do not get total client count if only 1 SSID
42
        if (count($total_oids) > 1) {
43
            // Find Total Client Count
44
            $oid = '.1.3.6.1.4.1.25053.1.2.1.1.1.15.2.0'; //RUCKUS-ZD-SYSTEM-MIB::ruckusZDSystemStatsNumSta.0
45
            array_push($sensors, new WirelessSensor('clients', $this->getDeviceId(), $oid, 'ruckuswireless', ($index + 1), 'System Total:'));
46
        }
47
48
        return $sensors;
49
    }
50
51
    // Find Total AP Count
52
53
    public function discoverWirelessApCount()
54
    {
55
        $oidconnected = '.1.3.6.1.4.1.25053.1.2.1.1.1.15.1.0'; //RUCKUS-ZD-SYSTEM-MIB::ruckusZDSystemStatsNumAP.0
56
        $oidtotal = '.1.3.6.1.4.1.25053.1.2.1.1.1.15.15.0'; //RUCKUS-ZD-SYSTEM-MIB::ruckusZDSystemStatsNumRegisteredAP.0
57
        $sensorindex = 0;
58
        $sensors[] = new WirelessSensor(
0 ignored issues
show
Comprehensibility Best Practice introduced by
$sensors was never initialized. Although not strictly required by PHP, it is generally a good practice to add $sensors = array(); before regardless.
Loading history...
59
                    'ap-count',
60
                    $this->getDeviceId(),
61
                    $oidconnected,
62
                    'ruckuswireless',
63
                    ++$sensorindex,
64
                    'Connected APs'
65
                );
66
67
        array_push($sensors, new WirelessSensor('ap-count', $this->getDeviceId(), $oidtotal, 'ruckuswireless', ++$sensorindex, 'Total APs'));
68
69
        return $sensors;
70
    }
71
}
72