Skip to content

Commit ae23e4a

Browse files
committed
fix replacement errors
1 parent 6eee008 commit ae23e4a

26 files changed

+164
-144
lines changed

LibreNMS/OS/ArubaInstant.php

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use LibreNMS\OS;
4646
use LibreNMS\Util\Mac;
4747
use LibreNMS\Util\Number;
48+
use SnmpQuery;
4849

4950
class ArubaInstant extends OS implements
5051
OSDiscovery,
@@ -74,13 +75,12 @@ public function discoverOS(Device $device): void
7475
public function discoverProcessors()
7576
{
7677
$processors = [];
77-
$ai_mib = 'AI-AP-MIB';
78-
$ai_ap_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
78+
$ai_ap_data = SnmpQuery::hideMib()->walk('AI-AP-MIB::discoverProcessors')->table(1);
7979

8080
foreach ($ai_ap_data as $ai_ap => $ai_ap_oid) {
8181
$value = $ai_ap_oid['aiAPCPUUtilization'];
8282
$mac = Mac::parse($ai_ap);
83-
$combined_oid = sprintf('%s::%s.%s', $ai_mib, 'aiAPCPUUtilization', $mac->oid());
83+
$combined_oid = sprintf('%s::%s.%s', 'AI-AP-MIB', 'aiAPCPUUtilization', $mac->oid());
8484
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
8585
$description = $ai_ap_data[$ai_ap]['aiAPSerialNum'];
8686
$processors[] = Processor::discover('aruba-instant', $this->getDeviceId(), $oid, $mac->hex(), $description, 1, $value);
@@ -99,23 +99,21 @@ public function discoverWirelessClients()
9999
{
100100
$sensors = [];
101101
$device = $this->getDeviceArray();
102-
$ai_mib = 'AI-AP-MIB';
103-
104102
if (intval(explode('.', $device['version'])[0]) >= 8 && intval(explode('.', $device['version'])[1]) >= 4) {
105103
// version is at least 8.4.0.0
106-
$ssid_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
104+
$ssid_data = SnmpQuery::hideMib()->walk('AI-AP-MIB::aiWlanSSIDTable')->table(1);
107105

108-
$ap_data = array_merge_recursive(
109-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1),
110-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1)
111-
);
106+
$ap_data = SnmpQuery::hideMib()->walk([
107+
'AI-AP-MIB::aiAccessPointTable',
108+
'AI-AP-MIB::aiRadioClientNum',
109+
])->table(1);
112110

113111
$oids = [];
114112
$total_clients = 0;
115113

116114
// Clients Per SSID
117115
foreach ($ssid_data as $index => $entry) {
118-
$combined_oid = sprintf('%s::%s.%s', $ai_mib, 'aiSSIDClientNum', $index);
116+
$combined_oid = sprintf('%s::%s.%s', 'AI-AP-MIB', 'aiSSIDClientNum', $index);
119117
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
120118
$description = sprintf('SSID %s Clients', $entry['aiSSID']);
121119
$oids[] = $oid;
@@ -129,7 +127,7 @@ public function discoverWirelessClients()
129127
// Clients Per Radio
130128
foreach ($ap_data as $index => $entry) {
131129
foreach ($entry['aiRadioClientNum'] as $radio => $value) {
132-
$combined_oid = sprintf('%s::%s.%s.%s', $ai_mib, 'aiRadioClientNum', Mac::parse($index)->oid(), $radio);
130+
$combined_oid = sprintf('%s::%s.%s.%s', 'AI-AP-MIB', 'aiRadioClientNum', Mac::parse($index)->oid(), $radio);
133131
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
134132
$description = sprintf('%s Radio %s', $entry['aiAPSerialNum'], $radio);
135133
$sensor_index = sprintf('%s.%s', Mac::parse($index)->hex(), $radio);
@@ -139,11 +137,11 @@ public function discoverWirelessClients()
139137
} else {
140138
// version is lower than 8.4.0.0
141139
// fetch the MAC addresses of currently connected clients, then count them to get an overall total
142-
$client_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
140+
$client_data = SnmpQuery::hideMib()->walk('AI-AP-MIB::aiClientMACAddress')->table(1);
143141

144142
$total_clients = count($client_data);
145143

146-
$combined_oid = sprintf('%s::%s', $ai_mib, 'aiClientMACAddress');
144+
$combined_oid = sprintf('%s::%s', 'AI-AP-MIB', 'aiClientMACAddress');
147145
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
148146

149147
$sensors[] = new WirelessSensor('clients', $this->getDeviceId(), $oid, 'aruba-instant', 'total-clients', 'Total Clients', $total_clients);
@@ -161,12 +159,11 @@ public function discoverWirelessClients()
161159
public function discoverWirelessApCount()
162160
{
163161
$sensors = [];
164-
$ai_mib = 'AI-AP-MIB';
165-
$ap_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
162+
$ap_data = SnmpQuery::walk('AI-AP-MIB::aiAPSerialNum')->table(1);
166163

167164
$total_aps = count($ap_data);
168165

169-
$combined_oid = sprintf('%s::%s', $ai_mib, 'aiAPSerialNum');
166+
$combined_oid = sprintf('%s::%s', 'AI-AP-MIB', 'aiAPSerialNum');
170167
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
171168

172169
$sensors[] = new WirelessSensor('ap-count', $this->getDeviceId(), $oid, 'aruba-instant', 'total-aps', 'Total APs', $total_aps);
@@ -229,14 +226,13 @@ public function discoverWirelessUtilization()
229226
*/
230227
private function discoverInstantRadio($type, $mib, $desc = '%s Radio %s')
231228
{
232-
$ai_mib = 'AI-AP-MIB';
233-
$ai_sg_data = array_merge_recursive(
234-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1),
235-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1),
236-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1),
237-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1),
238-
SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1)
239-
);
229+
$ai_sg_data = SnmpQuery::cache()->hideMib()->walk([
230+
'AI-AP-MIB::aiAPSerialNum',
231+
'AI-AP-MIB::aiRadioChannel',
232+
'AI-AP-MIB::aiRadioNoiseFloor',
233+
'AI-AP-MIB::aiRadioTransmitPower',
234+
'AI-AP-MIB::aiRadioUtilization64',
235+
])->table(1);
240236

241237
$sensors = [];
242238

@@ -253,7 +249,7 @@ private function discoverInstantRadio($type, $mib, $desc = '%s Radio %s')
253249
$value = $value * $multiplier;
254250
}
255251

256-
$combined_oid = sprintf('%s::%s.%s.%s', $ai_mib, $mib, Mac::parse($ai_ap)->oid(), $ai_ap_radio);
252+
$combined_oid = sprintf('%s::%s.%s.%s', 'AI-AP-MIB', $mib, Mac::parse($ai_ap)->oid(), $ai_ap_radio);
257253
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
258254
$description = sprintf($desc, $ai_sg_data[$ai_ap]['aiAPSerialNum'], $ai_ap_radio);
259255
$index = sprintf('%s.%s', Mac::parse($ai_ap)->hex(), $ai_ap_radio);
@@ -315,8 +311,7 @@ public function pollWirelessClients(array $sensors)
315311
} else {
316312
// version is lower than 8.4.0.0
317313
if (! empty($sensors) && count($sensors) == 1) {
318-
$ai_mib = 'AI-AP-MIB';
319-
$client_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
314+
$client_data = SnmpQuery::walk('AI-AP-MIB::aiClientMACAddress')->table(1);
320315

321316
if (empty($client_data)) {
322317
$total_clients = 0;
@@ -343,8 +338,7 @@ public function pollWirelessApCount(array $sensors)
343338
{
344339
$data = [];
345340
if (! empty($sensors) && count($sensors) == 1) {
346-
$ai_mib = 'AI-AP-MIB';
347-
$ap_data = SnmpQuery::hideMib()->walk("$ai_mib::oid")->table(1);
341+
$ap_data = SnmpQuery::walk('AI-AP-MIB::aiAPSerialNum')->table(1);
348342

349343
$total_aps = 0;
350344

LibreNMS/OS/Arubaos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function discoverWirelessClients()
8686
public function discoverWirelessApCount()
8787
{
8888
$mib = 'WLSX-SWITCH-MIB';
89-
$data = SnmpQuery::hideMib()->walk("$mib::oid")->table(1);
89+
$data = SnmpQuery::hideMib()->walk("$mib::wlsxSwitchTotalNumAccessPoints")->table(1);
9090
$sensors = [];
9191

9292
foreach ($data as $key => $value) {

LibreNMS/OS/AviatWtm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery;
3434
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
3535
use LibreNMS\OS;
36+
use SnmpQuery;
3637

3738
class AviatWtm extends OS implements
3839
OSDiscovery,

LibreNMS/OS/Ceraos.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRateDiscovery;
3737
use LibreNMS\Interfaces\Discovery\Sensors\WirelessXpiDiscovery;
3838
use LibreNMS\OS;
39+
use SnmpQuery;
3940

4041
class Ceraos extends OS implements OSDiscovery, WirelessXpiDiscovery, WirelessFrequencyDiscovery, WirelessErrorsDiscovery, WirelessMseDiscovery, WirelessPowerDiscovery, WirelessRateDiscovery
4142
{

LibreNMS/OS/Comware.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
3636
use LibreNMS\Interfaces\Discovery\TransceiverDiscovery;
3737
use LibreNMS\OS;
38+
use SnmpQuery;
3839

3940
class Comware extends OS implements MempoolsDiscovery, ProcessorDiscovery, TransceiverDiscovery
4041
{

LibreNMS/OS/Dnos.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use LibreNMS\Device\Processor;
3030
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
3131
use LibreNMS\OS;
32+
use SnmpQuery;
3233

3334
class Dnos extends OS implements ProcessorDiscovery
3435
{

LibreNMS/OS/Ericsson6600.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRateDiscovery;
3232
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
3333
use LibreNMS\OS;
34+
use SnmpQuery;
3435

3536
class Ericsson6600 extends OS implements
3637
WirelessFrequencyDiscovery,
@@ -43,7 +44,7 @@ public function discoverWirelessSnr()
4344
$sensors = [];
4445

4546
$data = snmpwalk_cache_oid($this->getDeviceArray(), 'xfCarrierTermSNIR', [], 'XF-RADIOLINK-RLT-MIB');
46-
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-RLT-MIB::oid')->table(1);
47+
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-RLT-MIB::xfCarrierTermDistinguishedName')->table(1);
4748
foreach ($data as $index => $entry) {
4849
$sensors[] = new WirelessSensor(
4950
'snr',
@@ -66,7 +67,7 @@ public function discoverWirelessRate()
6667
$sensors = [];
6768

6869
$data = snmpwalk_cache_oid($this->getDeviceArray(), 'xfCarrierTermActualCapacity', [], 'XF-RADIOLINK-RLT-MIB');
69-
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-RLT-MIB::oid')->table(1);
70+
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-RLT-MIB::xfCarrierTermDistinguishedName')->table(1);
7071
foreach ($data as $index => $entry) {
7172
$sensors[] = new WirelessSensor(
7273
'rate',
@@ -90,15 +91,15 @@ public function discoverWirelessFrequency()
9091

9192
$data_tx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFBaseTxFrequency', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
9293
$data_rx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFBaseRxFrequency', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
93-
$ifname = SnmpQuery::hideMib()->walk('IF-MIB::oid')->table(1);
94+
$ifname = SnmpQuery::cache()->walk('IF-MIB::ifName')->table(1);
9495
foreach ($data_tx as $index => $entry) {
9596
$sensors[] = new WirelessSensor(
9697
'frequency',
9798
$this->getDeviceId(),
9899
'.1.3.6.1.4.1.193.81.3.4.3.1.2.1.1.' . $index,
99100
'ericsson-6600',
100101
$index . 'tx',
101-
'TX Frequency: ' . $ifname[$index]['ifName'],
102+
'TX Frequency: ' . $ifname[$index]['IF-MIB::ifName'],
102103
null,
103104
1,
104105
1000
@@ -111,7 +112,7 @@ public function discoverWirelessFrequency()
111112
'.1.3.6.1.4.1.193.81.3.4.3.1.2.1.2.' . $index,
112113
'ericsson-6600',
113114
$index . 'rx',
114-
'RX Frequency: ' . $ifname[$index]['ifName'],
115+
'RX Frequency: ' . $ifname[$index]['IF-MIB::ifName'],
115116
null,
116117
1,
117118
1000
@@ -127,15 +128,15 @@ public function discoverWirelessPower()
127128

128129
$data_tx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRfCurrentOutputPower', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
129130
$data_rx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRfCurrentInputPower', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
130-
$ifname = SnmpQuery::hideMib()->walk('IF-MIB::oid')->table(1);
131+
$ifname = SnmpQuery::cache()->walk('IF-MIB::ifName')->table(1);
131132
foreach ($data_tx as $index => $entry) {
132133
$sensors[] = new WirelessSensor(
133134
'power',
134135
$this->getDeviceId(),
135136
'.1.3.6.1.4.1.193.81.3.4.3.1.8.1.3.' . $index,
136137
'ericsson-6600',
137138
$index . 'tx',
138-
'Output power: ' . $ifname[$index]['ifName'],
139+
'Output power: ' . $ifname[$index]['IF-MIB::ifName'],
139140
);
140141
}
141142
foreach ($data_rx as $index => $entry) {
@@ -145,7 +146,7 @@ public function discoverWirelessPower()
145146
'.1.3.6.1.4.1.193.81.3.4.3.1.8.1.7.' . $index,
146147
'ericsson-6600',
147148
$index . 'rx',
148-
'Input power: ' . $ifname[$index]['ifName'],
149+
'Input power: ' . $ifname[$index]['IF-MIB::ifName'],
149150
null,
150151
1,
151152
10

LibreNMS/OS/EricssonTn.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use LibreNMS\Interfaces\Discovery\Sensors\WirelessPowerDiscovery;
3232
use LibreNMS\Interfaces\Discovery\Sensors\WirelessRateDiscovery;
3333
use LibreNMS\OS;
34+
use SnmpQuery;
3435

3536
class EricssonTn extends OS implements
3637
WirelessMseDiscovery,
@@ -43,15 +44,15 @@ public function discoverWirelessMSE()
4344
$sensors = [];
4445

4546
$data = snmpwalk_cache_oid($this->getDeviceArray(), 'xfModemEntry', [], 'XF-RADIOLINK-PTP-MODEM-MIB');
46-
$ifname = SnmpQuery::hideMib()->walk('ENTITY-MIB::oid')->table(1);
47+
$ifname = SnmpQuery::cache()->walk('ENTITY-MIB::entPhysicalName')->table(1);
4748
foreach ($data as $index => $entry) {
4849
$sensors[] = new WirelessSensor(
4950
'mse',
5051
$this->getDeviceId(),
5152
'.1.3.6.1.4.1.193.81.3.4.2.1.1.1.15.' . $index,
5253
'ericsson-tn',
5354
$index,
54-
'MSE RAU: ' . ($ifname[$index]['entPhysicalName'] ?? null),
55+
'MSE RAU: ' . ($ifname[$index]['ENTITY-MIB::entPhysicalName'] ?? null),
5556
null,
5657
1,
5758
10
@@ -66,7 +67,7 @@ public function discoverWirelessRate()
6667
$sensors = [];
6768

6869
$data = snmpwalk_cache_oid($this->getDeviceArray(), 'xfTermBitPipeCapacity', [], 'XF-RADIOLINK-PTP-TERMINAL-MIB');
69-
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-PTP-TERMINAL-MIB::oid')->table(1);
70+
$carrier = SnmpQuery::hideMib()->walk('XF-RADIOLINK-PTP-TERMINAL-MIB::xfTermSysName')->table(1);
7071
foreach ($data as $index => $entry) {
7172
$sensors[] = new WirelessSensor(
7273
'rate',
@@ -90,15 +91,15 @@ public function discoverWirelessFrequency()
9091

9192
$data_tx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFBaseTxFrequency', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
9293
$data_rx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFBaseRxFrequency', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
93-
$ifname = SnmpQuery::hideMib()->walk('IF-MIB::oid')->table(1);
94+
$ifname = SnmpQuery::cache()->walk('IF-MIB::ifName')->table(1);
9495
foreach ($data_tx as $index => $entry) {
9596
$sensors[] = new WirelessSensor(
9697
'frequency',
9798
$this->getDeviceId(),
9899
'.1.3.6.1.4.1.193.81.3.4.3.1.2.1.1.' . $index,
99100
'ericsson-tn',
100101
$index . 'tx',
101-
'TX Frequency: ' . $ifname[$index]['ifName'],
102+
'TX Frequency: ' . $ifname[$index]['IF-MIB::ifName'],
102103
null,
103104
1,
104105
1000
@@ -111,7 +112,7 @@ public function discoverWirelessFrequency()
111112
'.1.3.6.1.4.1.193.81.3.4.3.1.2.1.2.' . $index,
112113
'ericsson-tn',
113114
$index . 'rx',
114-
'RX Frequency: ' . $ifname[$index]['ifName'],
115+
'RX Frequency: ' . $ifname[$index]['IF-MIB::ifName'],
115116
null,
116117
1,
117118
1000
@@ -127,15 +128,15 @@ public function discoverWirelessPower()
127128

128129
$data_tx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFCurrentOutputPower', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
129130
$data_rx = snmpwalk_cache_oid($this->getDeviceArray(), 'xfRFCurrentInputPower', [], 'XF-RADIOLINK-PTP-RADIO-MIB');
130-
$ifname = SnmpQuery::hideMib()->walk('IF-MIB::oid')->table(1);
131+
$ifname = SnmpQuery::cache()->walk('IF-MIB::ifName')->table(1);
131132
foreach ($data_tx as $index => $entry) {
132133
$sensors[] = new WirelessSensor(
133134
'power',
134135
$this->getDeviceId(),
135136
'.1.3.6.1.4.1.193.81.3.4.3.1.3.1.1.' . $index,
136137
'ericsson-tn',
137138
$index . 'tx',
138-
'Output power: ' . $ifname[$index]['ifName'],
139+
'Output power: ' . $ifname[$index]['IF-MIB::ifName'],
139140
);
140141
}
141142
foreach ($data_rx as $index => $entry) {
@@ -145,7 +146,7 @@ public function discoverWirelessPower()
145146
'.1.3.6.1.4.1.193.81.3.4.3.1.3.1.10.' . $index,
146147
'ericsson-tn',
147148
$index . 'rx',
148-
'Input power: ' . $ifname[$index]['ifName'],
149+
'Input power: ' . $ifname[$index]['IF-MIB::ifName'],
149150
null,
150151
1,
151152
10

LibreNMS/OS/Ewc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use LibreNMS\Interfaces\Discovery\Sensors\WirelessSnrDiscovery;
3636
use LibreNMS\Interfaces\Discovery\Sensors\WirelessUtilizationDiscovery;
3737
use LibreNMS\OS;
38+
use SnmpQuery;
3839

3940
class Ewc extends OS implements
4041
WirelessApCountDiscovery,

LibreNMS/OS/Fortiap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use LibreNMS\Interfaces\Discovery\Sensors\WirelessPowerDiscovery;
2222
use LibreNMS\Interfaces\Polling\Sensors\WirelessFrequencyPolling;
2323
use LibreNMS\OS\Shared\Fortinet;
24+
use SnmpQuery;
2425

2526
class Fortiap extends Fortinet implements
2627
OSDiscovery,

0 commit comments

Comments
 (0)