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 | $fields = [ |
||
21 | 'fecInErrorsCount' => $fecInErrorsCount, |
||
22 | 'fecOutErrorsCount' => $fecOutErrorsCount, |
||
23 | ]; |
||
24 | $tags = compact('rrd_def'); |
||
25 | data_update($device, 'cambium-generic-errorCount', $tags, $fields); |
||
26 | $os->enableGraph('cambium_generic_errorCount'); |
||
27 | unset($rrd_filename, $fecInErrorsCount, $fecOutErrorsCount); |
||
28 | } |
||
29 | |||
30 | $crcErrors = snmp_get($device, 'fecCRCError.0', '-Ovqn', 'WHISP-BOX-MIBV2-MIB'); |
||
31 | if (is_numeric($crcErrors)) { |
||
32 | $rrd_def = RrdDefinition::make()->addDataset('crcErrors', 'GAUGE', 0, 100000); |
||
33 | $fields = [ |
||
34 | 'crcErrors' => $crcErrors, |
||
35 | ]; |
||
36 | $tags = compact('rrd_def'); |
||
37 | data_update($device, 'cambium-generic-crcErrors', $tags, $fields); |
||
38 | $os->enableGraph('cambium_generic_crcErrors'); |
||
39 | } |
||
40 | |||
41 | $vertical = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.2.2.117.0', '-Ovqn', '')); |
||
42 | $horizontal = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.2.2.118.0', '-Ovqn', '')); |
||
43 | $combined = snmp_get($device, '1.3.6.1.4.1.161.19.3.2.2.21.0', '-Ovqn', ''); |
||
44 | if (is_numeric($vertical) && is_numeric($horizontal) && is_numeric($combined)) { |
||
45 | $rrd_def = RrdDefinition::make() |
||
46 | ->addDataset('vertical', 'GAUGE', -150, 0) |
||
47 | ->addDataset('horizontal', 'GAUGE', -150, 0) |
||
48 | ->addDataset('combined', 'GAUGE', -150, 0); |
||
49 | $fields = [ |
||
50 | 'vertical' => floatval($vertical), |
||
51 | 'horizontal' => floatval($horizontal), |
||
52 | 'combined' => $combined, |
||
53 | ]; |
||
54 | $tags = compact('rrd_def'); |
||
55 | data_update($device, 'cambium-generic-signalHV', $tags, $fields); |
||
56 | $os->enableGraph('cambium_generic_signalHV'); |
||
57 | unset($rrd_filename, $vertical, $horizontal, $combined); |
||
58 | } |
||
59 | |||
60 | $rssi = snmp_get($device, '1.3.6.1.4.1.161.19.3.2.2.2.0', '-Ovqn', ''); |
||
61 | if (is_numeric($rssi)) { |
||
62 | $rrd_def = RrdDefinition::make()->addDataset('rssi', 'GAUGE', 0, 5000); |
||
63 | $fields = [ |
||
64 | 'rssi' => $rssi, |
||
65 | ]; |
||
66 | $tags = compact('rrd_def'); |
||
67 | data_update($device, 'cambium-generic-rssi', $tags, $fields); |
||
68 | $os->enableGraph('cambium_generic_rssi'); |
||
69 | unset($rrd_filename, $rssi); |
||
70 | } |
||
71 | |||
72 | $jitter = snmp_get($device, 'jitter.0', '-Ovqn', 'WHISP-SM-MIB'); |
||
73 | if (is_numeric($jitter)) { |
||
74 | $rrd_def = RrdDefinition::make()->addDataset('jitter', 'GAUGE', 0, 20); |
||
75 | $fields = [ |
||
76 | 'jitter' => $jitter, |
||
77 | ]; |
||
78 | $tags = compact('rrd_def'); |
||
79 | data_update($device, 'cambium-generic-jitter', $tags, $fields); |
||
80 | $os->enableGraph('cambium_generic_jitter'); |
||
81 | unset($rrd_filename, $jitter); |
||
82 | } |
||
83 | |||
84 | $horizontal = str_replace('"', '', snmp_get($device, 'radioDbmHorizontal.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
85 | $vertical = str_replace('"', '', snmp_get($device, 'radioDbmVertical.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
86 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
87 | $rrd_def = RrdDefinition::make() |
||
88 | ->addDataset('horizontal', 'GAUGE', -100, 100) |
||
89 | ->addDataset('vertical', 'GAUGE', -100, 100); |
||
90 | $fields = [ |
||
91 | 'horizontal' => $horizontal, |
||
92 | 'vertical' => $vertical, |
||
93 | ]; |
||
94 | $tags = compact('rrd_def'); |
||
95 | data_update($device, 'cambium-generic-450-slaveHV', $tags, $fields); |
||
96 | $os->enableGraph('cambium_generic_450_slaveHV'); |
||
97 | unset($rrd_filename, $horizontal, $vertical); |
||
98 | } |
||
99 | |||
100 | $ssr = str_replace('"', '', snmp_get($device, 'signalStrengthRatio.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
101 | if (is_numeric($ssr)) { |
||
102 | $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); |
||
103 | $fields = [ |
||
104 | 'ssr' => $ssr, |
||
105 | ]; |
||
106 | $tags = compact('rrd_def'); |
||
107 | data_update($device, 'cambium-generic-450-slaveSSR', $tags, $fields); |
||
108 | $os->enableGraph('cambium_generic_450_slaveSSR'); |
||
109 | unset($rrd_filename, $ssr); |
||
110 | } |
||
111 | |||
112 | $horizontal = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioSMHorizontal.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
113 | $vertical = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioSMVertical.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
114 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
115 | $rrd_def = RrdDefinition::make() |
||
116 | ->addDataset('horizontal', 'GAUGE', 0, 100) |
||
117 | ->addDataset('vertical', 'GAUGE', 0, 100); |
||
118 | $fields = [ |
||
119 | 'horizontal' => $horizontal, |
||
120 | 'vertical' => $vertical, |
||
121 | ]; |
||
122 | $tags = compact('rrd_def'); |
||
123 | data_update($device, 'cambium-generic-450-slaveSNR', $tags, $fields); |
||
124 | $os->enableGraph('cambium_generic_450_slaveSNR'); |
||
125 | unset($rrd_filename, $horizontal, $vertical); |
||
126 | } |
||
127 | } |
||
128 | |||
129 | if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, 'CMM')) { |
||
130 | $gpsStatus = snmp_get($device, 'whispGPSStats.0', '-Ovqn', 'WHISP-APS-MIB'); |
||
131 | if ($gpsStatus == 'generatingSync') { |
||
132 | $gpsStatus = 3; |
||
133 | } elseif ($gpsStatus == 'gpsLostSync') { |
||
134 | $gpsStatus = 2; |
||
135 | } elseif ($gpsStatus == 'gpsSynchronized') { |
||
136 | $gpsStatus = 1; |
||
137 | } |
||
138 | if (is_numeric($gpsStatus)) { |
||
139 | $rrd_def = RrdDefinition::make()->addDataset('whispGPSStats', 'GAUGE', 0, 4); |
||
140 | $fields = [ |
||
141 | 'whispGPSStats' => $gpsStatus, |
||
142 | ]; |
||
143 | $tags = compact('rrd_def'); |
||
144 | data_update($device, 'cambium-generic-whispGPSStats', $tags, $fields); |
||
145 | $os->enableGraph('cambium_generic_whispGPSStats'); |
||
146 | unset($rrd_filename, $gpsStatus); |
||
147 | } |
||
148 | |||
149 | $visible = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.4.4.7.0', '-Ovqn', '')); |
||
150 | $tracked = str_replace('"', '', snmp_get($device, '.1.3.6.1.4.1.161.19.3.4.4.8.0', '-Ovqn', '')); |
||
151 | if (is_numeric($visible) && is_numeric($tracked)) { |
||
152 | $rrd_def = RrdDefinition::make() |
||
153 | ->addDataset('visible', 'GAUGE', 0, 1000) |
||
154 | ->addDataset('tracked', 'GAUGE', 0, 1000); |
||
155 | $fields = [ |
||
156 | 'visible' => floatval($visible), |
||
157 | 'tracked' => floatval($tracked), |
||
158 | ]; |
||
159 | $tags = compact('rrd_def'); |
||
160 | data_update($device, 'cambium-generic-gpsStats', $tags, $fields); |
||
161 | $os->enableGraph('cambium_generic_gpsStats'); |
||
162 | unset($rrd_filename, $visible, $tracked); |
||
163 | } |
||
164 | } |
||
165 | //PTP Equipment |
||
166 | $lastLevel = str_replace('"', '', snmp_get($device, 'lastPowerLevel.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
167 | if (is_numeric($lastLevel)) { |
||
168 | $rrd_def = RrdDefinition::make()->addDataset('last', 'GAUGE', -100, 0); |
||
169 | $fields = [ |
||
170 | 'last' => $lastLevel, |
||
171 | ]; |
||
172 | $tags = compact('rrd_def'); |
||
173 | data_update($device, 'cambium-generic-450-powerlevel', $tags, $fields); |
||
174 | $os->enableGraph('cambium_generic_450_powerlevel'); |
||
175 | unset($lastLevel); |
||
176 | } |
||
177 | |||
178 | if (strstr($version, 'AP') == false) { |
||
0 ignored issues
–
show
|
|||
179 | $horizontal = str_replace('"', '', snmp_get($device, 'linkRadioDbmHorizontal.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
180 | $vertical = str_replace('"', '', snmp_get($device, 'linkRadioDbmVertical.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
181 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
182 | $rrd_def = RrdDefinition::make() |
||
183 | ->addDataset('horizontal', 'GAUGE', -100, 0) |
||
184 | ->addDataset('vertical', 'GAUGE', -100, 0); |
||
185 | $fields = [ |
||
186 | 'horizontal' => $horizontal, |
||
187 | 'vertical' => $vertical, |
||
188 | ]; |
||
189 | $tags = compact('rrd_def'); |
||
190 | data_update($device, 'cambium-generic-450-linkRadioDbm', $tags, $fields); |
||
191 | $os->enableGraph('cambium_generic_450_linkRadioDbm'); |
||
192 | unset($rrd_filename, $horizontal, $horizontal); |
||
193 | } |
||
194 | |||
195 | $horizontal = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioHorizontal.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
196 | $vertical = str_replace('"', '', snmp_get($device, 'signalToNoiseRatioVertical.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
197 | if (is_numeric($horizontal) && is_numeric($vertical)) { |
||
198 | $rrd_def = RrdDefinition::make() |
||
199 | ->addDataset('horizontal', 'GAUGE', 0, 100) |
||
200 | ->addDataset('vertical', 'GAUGE', 0, 100); |
||
201 | $fields = [ |
||
202 | 'horizontal' => $horizontal, |
||
203 | 'vertical' => $vertical, |
||
204 | ]; |
||
205 | $tags = compact('rrd_def'); |
||
206 | data_update($device, 'cambium-generic-450-ptpSNR', $tags, $fields); |
||
207 | $os->enableGraph('cambium_generic_450_ptpSNR'); |
||
208 | unset($rrd_filename, $horizontal, $horizontal); |
||
209 | } |
||
210 | |||
211 | $ssr = str_replace('"', '', snmp_get($device, 'linkSignalStrengthRatio.2', '-Ovqn', 'WHISP-APS-MIB')); |
||
212 | if (is_numeric($ssr)) { |
||
213 | $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); |
||
214 | $fields = [ |
||
215 | 'ssr' => $ssr, |
||
216 | ]; |
||
217 | $tags = compact('rrd_def'); |
||
218 | data_update($device, 'cambium-generic-450-masterSSR', $tags, $fields); |
||
219 | $os->enableGraph('cambium_generic_450_masterSSR'); |
||
220 | unset($rrd_filename, $ssr); |
||
221 | } |
||
222 | |||
223 | if (strstr($hardware, 'PTP 230')) { |
||
224 | $dbmRadio = str_replace('"', '', snmp_get($device, 'radioDbmInt.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
225 | $minRadio = str_replace('"', '', snmp_get($device, 'minRadioDbm.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
226 | $maxRadio = str_replace('"', '', snmp_get($device, 'maxRadioDbm.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
227 | $avgRadio = str_replace('"', '', snmp_get($device, 'radioDbmAvg.0', '-Ovqn', 'WHISP-SM-MIB')); |
||
228 | |||
229 | if (is_numeric($dbmRadio) && is_numeric($minRadio) && is_numeric($maxRadio) && is_numeric($avgRadio)) { |
||
230 | $rrd_def = RrdDefinition::make() |
||
231 | ->addDataset('dbm', 'GAUGE', -100, 0) |
||
232 | ->addDataset('min', 'GAUGE', -100, 0) |
||
233 | ->addDataset('max', 'GAUGE', -100, 0) |
||
234 | ->addDataset('avg', 'GAUGE', -100, 0); |
||
235 | $fields = [ |
||
236 | 'dbm' => $dbmRadio, |
||
237 | 'min' => $minRadio, |
||
238 | 'max' => $maxRadio, |
||
239 | 'avg' => $avgRadio, |
||
240 | ]; |
||
241 | $tags = compact('rrd_def'); |
||
242 | data_update($device, 'cambium-generic-radioDbm', $tags, $fields); |
||
243 | $os->enableGraph('cambium_generic_radioDbm'); |
||
244 | unset($rrd_filename, $dbmRadio, $minRadio, $maxRadio, $avgRadio); |
||
245 | } |
||
246 | } |
||
247 | } |
||
248 | |||
249 | //AP Equipment |
||
250 | if (strstr($version, 'AP')) { |
||
251 | $registered = str_replace('"', '', snmp_get($device, 'regCount.0', '-Ovqn', 'WHISP-APS-MIB')); |
||
252 | $failed = str_replace('"', '', snmp_get($device, 'regFailureCount.0', '-Ovqn', 'WHISP-APS-MIB')); |
||
253 | if (is_numeric($registered) && is_numeric($failed)) { |
||
254 | $rrd_def = RrdDefinition::make() |
||
255 | ->addDataset('regCount', 'GAUGE', 0, 15000) |
||
256 | ->addDataset('failed', 'GAUGE', 0, 15000); |
||
257 | $fields = [ |
||
258 | 'regCount' => $registered, |
||
259 | 'failed' => $failed, |
||
260 | ]; |
||
261 | $tags = compact('rrd_def'); |
||
262 | data_update($device, 'cambium-generic-regCount', $tags, $fields); |
||
263 | $os->enableGraph('cambium_generic_regCount'); |
||
264 | unset($rrd_filename, $registered, $failed); |
||
265 | } |
||
266 | |||
267 | $freq = str_replace('"', '', snmp_get($device, 'currentRadioFreqCarrier.0', '-Ovqn', 'WHISP-APS-MIB')); |
||
268 | if (is_numeric($freq)) { |
||
269 | $rrd_def = RrdDefinition::make()->addDataset('freq', 'GAUGE', 0, 100000); |
||
270 | if ($freq > 99999) { |
||
271 | $freq = $freq / 100000; |
||
272 | } else { |
||
273 | $freq = $freq / 10000; |
||
274 | } |
||
275 | $fields = [ |
||
276 | 'freq' => $freq, |
||
277 | ]; |
||
278 | $tags = compact('rrd_def'); |
||
279 | data_update($device, 'cambium-generic-freq', $tags, $fields); |
||
280 | $os->enableGraph('cambium_generic_freq'); |
||
281 | unset($rrd_filename, $freq); |
||
282 | } |
||
283 | } |
||
284 |