Check for loose comparison of strings with boolean.
1 | <?php |
||
2 | /* |
||
3 | * LibreNMS |
||
4 | * |
||
5 | * This program is free software: you can redistribute it and/or modify it |
||
6 | * under the terms of the GNU General Public License as published by the |
||
7 | * Free Software Foundation, either version 3 of the License, or (at your |
||
8 | * option) any later version. Please see LICENSE.txt at the top level of |
||
9 | * the source code distribution for details. |
||
10 | */ |
||
11 | use LibreNMS\RRD\RrdDefinition; |
||
12 | |||
13 | if (strstr($hardware, 'CMM') == false) { |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
14 | $fecInErrorsCount = snmp_get($device, 'fecInErrorsCount.0', '-Ovqn', 'WHISP-BOX-MIBV2-MIB'); |
||
15 | $fecOutErrorsCount = snmp_get($device, 'fecOutErrorsCount.0', '-Ovqn', 'WHISP-BOX-MIBV2-MIB'); |
||
16 | if (is_numeric($fecInErrorsCount) && is_numeric($fecOutErrorsCount)) { |
||
17 | $rrd_def = RrdDefinition::make() |
||
18 | ->addDataset('fecInErrorsCount', 'GAUGE', 0, 100000) |
||
19 | ->addDataset('fecOutErrorsCount', 'GAUGE', 0, 100000); |
||
20 | |||
21 | $fields = [ |
||
22 | 'fecInErrorsCount' => $fecInErrorsCount, |
||
23 | 'fecOutErrorsCount' => $fecOutErrorsCount, |
||
24 | ]; |
||
25 | $tags = compact('rrd_def'); |
||
26 | data_update($device, 'canopy-generic-errorCount', $tags, $fields); |
||
27 | $os->enableGraph('canopy_generic_errorCount'); |
||
28 | unset($rrd_filename, $fecInErrorsCount, $fecOutErrorsCount); |
||
29 | } |
||
30 | |||
31 | $crcErrors = snmp_get($device, 'fecCRCError.0', '-Ovqn', 'WHISP-BOX-MIBV2-MIB'); |
||
32 | if (is_numeric($crcErrors)) { |
||
33 | $rrd_def = RrdDefinition::make()->addDataset('crcErrors', 'GAUGE', 0, 100000); |
||
34 | $fields = [ |
||
35 | 'crcErrors' => $crcErrors, |
||
36 | ]; |
||
37 | $tags = compact('rrd_def'); |
||
38 | data_update($device, 'canopy-generic-crcErrors', $tags, $fields); |
||
39 | $os->enableGraph('canopy_generic_crcErrors'); |
||
40 | } |
||
41 | |||
42 | $vertical = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.2.2.117.0', '-Ovqn', '')); |
||
43 | $horizontal = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.2.2.118.0', '-Ovqn', '')); |
||
44 | $combined = snmp_get($device, '1.3.6.1.4.1.161.19.3.2.2.21.0', '-Ovqn', ''); |
||
45 | if (is_numeric($vertical) && is_numeric($horizontal) && is_numeric($combined)) { |
||
46 | $rrd_def = RrdDefinition::make() |
||
47 | ->addDataset('vertical', 'GAUGE', -150, 0) |
||
48 | ->addDataset('horizontal', 'GAUGE', -150, 0) |
||
49 | ->addDataset('combined', 'GAUGE', -150, 0); |
||
50 | $fields = [ |
||
51 | 'vertical' => floatval($vertical), |
||
52 | 'horizontal' => floatval($horizontal), |
||
53 | 'combined' => $combined, |
||
54 | ]; |
||
55 | $tags = compact('rrd_def'); |
||
56 | data_update($device, 'canopy-generic-signalHV', $tags, $fields); |
||
57 | $os->enableGraph('canopy_generic_signalHV'); |
||
58 | unset($rrd_filename, $vertical, $horizontal, $combined); |
||
59 | } |
||
60 | |||
61 | // Implemented |
||
62 | // $rssi = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.2.0", "-Ovqn", ""); |
||
63 | // if (is_numeric($rssi)) { |
||
64 | // $rrd_def = RrdDefinition::make()->addDataset('rssi', 'GAUGE', 0, 5000); |
||
65 | // $fields = array( |
||
66 | // 'rssi' => $rssi, |
||
67 | // ); |
||
68 | // $tags = compact('rrd_def'); |
||
69 | // data_update($device, 'canopy-generic-rssi', $tags, $fields); |
||
70 | // $os->enableGraph('canopy_generic_rssi'); |
||
71 | // unset($rrd_filename, $rssi); |
||
72 | // } |
||
73 | |||
74 | $jitter = snmp_get($device, 'jitter.0', '-Ovqn', 'WHISP-SM-MIB'); |
||
75 | if (is_numeric($jitter)) { |
||
76 | $rrd_def = RrdDefinition::make()->addDataset('jitter', 'GAUGE', 0, 20); |
||
77 | $fields = [ |
||
78 | 'jitter' => $jitter, |
||
79 | ]; |
||
80 | $tags = compact('rrd_def'); |
||
81 | data_update($device, 'canopy-generic-jitter', $tags, $fields); |
||
82 | $os->enableGraph('canopy_generic_jitter'); |
||
83 | unset($rrd_filename, $jitter); |
||
84 | } |
||
85 | |||
86 | $horizontal = str_replace('"', '', snmp_get($device, 'radioDbmHorizontal.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
87 | $vertical = str_replace('"', '', snmp_get($device, 'radioDbmVertical.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
88 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
89 | $rrd_def = RrdDefinition::make() |
||
90 | ->addDataset('horizontal', 'GAUGE', -100, 100) |
||
91 | ->addDataset('vertical', 'GAUGE', -100, 100); |
||
92 | |||
93 | $fields = [ |
||
94 | 'horizontal' => $horizontal, |
||
95 | 'vertical' => $vertical, |
||
96 | ]; |
||
97 | $tags = compact('rrd_def'); |
||
98 | data_update($device, 'canopy-generic-450-slaveHV', $tags, $fields); |
||
99 | $os->enableGraph('canopy_generic_450_slaveHV'); |
||
100 | unset($rrd_filename, $horizontal, $vertical); |
||
101 | } |
||
102 | |||
103 | $ssr = str_replace('"', '', snmp_get($device, 'signalStrengthRatio.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
104 | if (is_numeric($ssr)) { |
||
105 | $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); |
||
106 | $fields = [ |
||
107 | 'ssr' => $ssr, |
||
108 | ]; |
||
109 | $tags = compact('rrd_def'); |
||
110 | data_update($device, 'canopy-generic-450-slaveSSR', $tags, $fields); |
||
111 | $os->enableGraph('canopy_generic_450_slaveSSR'); |
||
112 | unset($rrd_filename, $ssr); |
||
113 | } |
||
114 | |||
115 | $horizontal = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioSMHorizontal.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
116 | $vertical = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioSMVertical.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
117 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
118 | $rrd_def = RrdDefinition::make() |
||
119 | ->addDataset('horizontal', 'GAUGE', 0, 100) |
||
120 | ->addDataset('vertical', 'GAUGE', 0, 100); |
||
121 | $fields = [ |
||
122 | 'horizontal' => $horizontal, |
||
123 | 'vertical' => $vertical, |
||
124 | ]; |
||
125 | $tags = compact('rrd_def'); |
||
126 | data_update($device, 'canopy-generic-450-slaveSNR', $tags, $fields); |
||
127 | $os->enableGraph('canopy_generic_450_slaveSNR'); |
||
128 | unset($rrd_filename, $horizontal, $vertical); |
||
129 | } |
||
130 | } |
||
131 | // Convert to: https://docs.librenms.org/#Developing/Sensor-State-Support/ |
||
132 | if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, 'CMM')) { |
||
133 | // Implemented |
||
134 | // $gpsStatus = snmp_get($device, "whispGPSStats.0", "-Ovqn", "WHISP-APS-MIB"); |
||
135 | // if ($gpsStatus == 'generatingSync') { |
||
136 | // $gpsStatus = 3; |
||
137 | // } elseif ($gpsStatus == 'gpsLostSync') { |
||
138 | // $gpsStatus = 2; |
||
139 | // } elseif ($gpsStatus == 'gpsSynchronized') { |
||
140 | // $gpsStatus = 1; |
||
141 | // } |
||
142 | // if (is_numeric($gpsStatus)) { |
||
143 | // $rrd_def = RrdDefinition::make()->addDataset('whispGPSStats', 'GAUGE', 0, 4); |
||
144 | // $fields = array( |
||
145 | // 'whispGPSStats' => $gpsStatus, |
||
146 | // ); |
||
147 | // $tags = compact('rrd_def'); |
||
148 | // data_update($device, 'canopy-generic-whispGPSStats', $tags, $fields); |
||
149 | // $os->enableGraph('canopy_generic_whispGPSStats'); |
||
150 | // unset($rrd_filename, $gpsStatus); |
||
151 | // } |
||
152 | |||
153 | $visible = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.4.4.7.0', '-Ovqn', '')); |
||
154 | $tracked = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.4.4.8.0', '-Ovqn', '')); |
||
155 | if (is_numeric($visible) && is_numeric($tracked)) { |
||
156 | $rrd_def = RrdDefinition::make() |
||
157 | ->addDataset('visible', 'GAUGE', 0, 1000) |
||
158 | ->addDataset('tracked', 'GAUGE', 0, 1000); |
||
159 | $fields = [ |
||
160 | 'visible' => floatval($visible), |
||
161 | 'tracked' => floatval($tracked), |
||
162 | ]; |
||
163 | $tags = compact('rrd_def'); |
||
164 | data_update($device, 'canopy-generic-gpsStats', $tags, $fields); |
||
165 | $os->enableGraph('canopy_generic_gpsStats'); |
||
166 | unset($rrd_filename, $visible, $tracked); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | if (strstr($version, 'AP') == false) { |
||
0 ignored issues
–
show
|
|||
171 | $horizontal = str_replace('"', '', snmp_get($device, 'linkRadioDbmHorizontal.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
172 | $vertical = str_replace('"', '', snmp_get($device, 'linkRadioDbmVertical.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
173 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
174 | $rrd_def = RrdDefinition::make() |
||
175 | ->addDataset('horizontal', 'GAUGE', -100, 0) |
||
176 | ->addDataset('vertical', 'GAUGE', -100, 0); |
||
177 | $fields = [ |
||
178 | 'horizontal' => $horizontal, |
||
179 | 'vertical' => $vertical, |
||
180 | ]; |
||
181 | $tags = compact('rrd_def'); |
||
182 | data_update($device, 'canopy-generic-450-linkRadioDbm', $tags, $fields); |
||
183 | $os->enableGraph('canopy_generic_450_linkRadioDbm'); |
||
184 | unset($rrd_filename, $horizontal, $horizontal); |
||
185 | } |
||
186 | |||
187 | $lastLevel = str_replace('"', '', snmp_get($device, 'lastPowerLevel.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
188 | if (is_numeric($lastLevel)) { |
||
189 | $rrd_def = RrdDefinition::make()->addDataset('last', 'GAUGE', -100, 0); |
||
190 | $fields = [ |
||
191 | 'last' => $lastLevel, |
||
192 | ]; |
||
193 | $tags = compact('rrd_def'); |
||
194 | data_update($device, 'canopy-generic-450-powerlevel', $tags, $fields); |
||
195 | $os->enableGraph('canopy_generic_450_powerlevel'); |
||
196 | unset($lastLevel); |
||
197 | } |
||
198 | |||
199 | // Implemented |
||
200 | // $horizontal = str_replace('"', "", snmp_get($device, "signalToNoiseRatioHorizontal.2", "-Ovqn", "WHISP-APS-MIB")); |
||
201 | // $vertical = str_replace('"', "", snmp_get($device, "signalToNoiseRatioVertical.2", "-Ovqn", "WHISP-APS-MIB")); |
||
202 | // if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
203 | // $rrd_def = RrdDefinition::m // ->addDataset('horizontal', 'GAUGE', 0, 100)ake() |
||
204 | |||
205 | // ->addDataset('vertical', 'GAUGE', 0, 100); |
||
206 | // $fields = array( |
||
207 | // 'horizontal' => $horizontal, |
||
208 | // 'vertical' => $vertical, |
||
209 | // ); |
||
210 | // $tags = compact('rrd_def'); |
||
211 | // data_update($device, 'canopy-generic-450-ptpSNR', $tags, $fields); |
||
212 | // $os->enableGraph('canopy_generic_450_ptpSNR'); |
||
213 | // unset($rrd_filename, $horizontal, $horizontal); |
||
214 | // } |
||
215 | |||
216 | $ssr = str_replace('"', '', snmp_get($device, 'linkSignalStrengthRatio.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
217 | if (is_numeric($ssr)) { |
||
218 | $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); |
||
219 | $fields = [ |
||
220 | 'ssr' => $ssr, |
||
221 | ]; |
||
222 | $tags = compact('rrd_def'); |
||
223 | data_update($device, 'canopy-generic-450-masterSSR', $tags, $fields); |
||
224 | $os->enableGraph('canopy_generic_450_masterSSR'); |
||
225 | unset($rrd_filename, $ssr); |
||
226 | } |
||
227 | |||
228 | if (strstr($hardware, 'PTP 230')) { |
||
229 | $dbmRadio = str_replace('"', '', snmp_get($device, 'radioDbmInt.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
230 | $minRadio = str_replace('"', '', snmp_get($device, 'minRadioDbm.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
231 | $maxRadio = str_replace('"', '', snmp_get($device, 'maxRadioDbm.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
232 | $avgRadio = str_replace('"', '', snmp_get($device, 'radioDbmAvg.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
233 | |||
234 | if (is_numeric($dbmRadio) && is_numeric($minRadio) && is_numeric($maxRadio) && is_numeric($avgRadio)) { |
||
235 | $rrd_def = RrdDefinition::make() |
||
236 | ->addDataset('dbm', 'GAUGE', -100, 0) |
||
237 | ->addDataset('min', 'GAUGE', -100, 0) |
||
238 | ->addDataset('max', 'GAUGE', -100, 0) |
||
239 | ->addDataset('avg', 'GAUGE', -100, 0); |
||
240 | |||
241 | $fields = [ |
||
242 | 'dbm' => $dbmRadio, |
||
243 | 'min' => $minRadio, |
||
244 | 'max' => $maxRadio, |
||
245 | 'avg' => $avgRadio, |
||
246 | ]; |
||
247 | $tags = compact('rrd_def'); |
||
248 | data_update($device, 'canopy-generic-radioDbm', $tags, $fields); |
||
249 | $os->enableGraph('canopy_generic_radioDbm'); |
||
250 | unset($rrd_filename, $dbmRadio, $minRadio, $maxRadio, $avgRadio); |
||
251 | } |
||
252 | } |
||
253 | } |
||
254 | |||
255 | //AP Equipment |
||
256 | if (strstr($version, 'AP')) { |
||
257 | $multi_get_array = snmp_get_multi($device, ['regCount.0', 'regFailureCount.0', 'currentRadioFreqCarrier.0', 'frUtlLowTotalDownlinkUtilization.0', 'frUtlLowTotalUplinkUtilization.0'], '-OQU', 'WHISP-APS-MIB'); |
||
258 | d_echo($multi_get_array); |
||
259 | $registered = $multi_get_array[0]['WHISP-APS-MIB::regCount']; |
||
260 | $failed = $multi_get_array[0]['WHISP-APS-MIB::regFailureCount']; |
||
261 | $freq = $multi_get_array[0]['WHISP-APS-MIB::currentRadioFreqCarrier']; |
||
262 | $downlinkutilization = $multi_get_array[0]['WHISP-APS-MIB::frUtlLowTotalDownlinkUtilization']; |
||
263 | $uplinkutilization = $multi_get_array[0]['WHISP-APS-MIB::frUtlLowTotalUplinkUtilization']; |
||
264 | |||
265 | if (is_numeric($registered) && is_numeric($failed)) { |
||
266 | $rrd_def = RrdDefinition::make() |
||
267 | ->addDataset('regCount', 'GAUGE', 0, 15000) |
||
268 | ->addDataset('failed', 'GAUGE', 0, 15000); |
||
269 | $fields = [ |
||
270 | 'regCount' => $registered, |
||
271 | 'failed' => $failed, |
||
272 | ]; |
||
273 | $tags = compact('rrd_def'); |
||
274 | data_update($device, 'canopy-generic-regCount', $tags, $fields); |
||
275 | $os->enableGraph('canopy_generic_regCount'); |
||
276 | unset($rrd_filename, $registered, $failed); |
||
277 | } |
||
278 | |||
279 | // Implemented |
||
280 | // if (is_numeric($freq)) { |
||
281 | // $rrd_def = RrdDefinition::make()->addDataset('freq', 'GAUGE', 0, 100000); |
||
282 | // if ($freq > 99999) { |
||
283 | // $freq = $freq / 100000; |
||
284 | // } else { |
||
285 | // $freq = $freq / 10000; |
||
286 | // } |
||
287 | // $fields = array( |
||
288 | // 'freq' => $freq, |
||
289 | // ); |
||
290 | // $tags = compact('rrd_def'); |
||
291 | // data_update($device, 'canopy-generic-freq', $tags, $fields); |
||
292 | // $os->enableGraph('canopy_generic_freq'); |
||
293 | // unset($rrd_filename, $freq); |
||
294 | // } |
||
295 | |||
296 | // implemented |
||
297 | // if (is_numeric($downlinkutilization) && is_numeric($uplinkutilization)) { |
||
298 | // $rrd_def = RrdDefinition::make() |
||
299 | // ->addDataset('downlinkutilization', 'GAUGE', 0, 15000) |
||
300 | // ->addDataset('uplinkutilization', 'GAUGE', 0, 15000); |
||
301 | // $fields = array( |
||
302 | // 'downlinkutilization' => $downlinkutilization, |
||
303 | // 'uplinkutilization' => $uplinkutilization, |
||
304 | // ); |
||
305 | // $tags = compact('rrd_def'); |
||
306 | // data_update($device, 'canopy-generic-frameUtilization', $tags, $fields); |
||
307 | // $os->enableGraph('canopy-generic-frameUtilization'); |
||
308 | // unset($rrd_filename, $downlinkutilization, $uplinkutilization); |
||
309 | // } |
||
310 | } |
||
311 |