1 | <?php |
||
2 | /** |
||
3 | * JnxLaneDomAlarmId.php |
||
4 | * |
||
5 | * -Description- |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation, either version 3 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
19 | * |
||
20 | * |
||
21 | * Used covert alarm ID in the JnxDomLaneAlarm traps from Hex to a |
||
22 | * descriptive string. |
||
23 | |||
24 | * @package LibreNMS |
||
25 | * @link http://librenms.org |
||
26 | * @copyright 2019 KanREN, Inc |
||
27 | * @author Heath Barnhart <[email protected]> |
||
28 | */ |
||
29 | |||
30 | namespace LibreNMS\Snmptrap\Handlers; |
||
31 | |||
32 | class JnxDomLaneAlarmId |
||
33 | { |
||
34 | public static function getLaneAlarms($currentAlarm) |
||
35 | { |
||
36 | $alarmBin = preg_split( |
||
37 | "//", |
||
38 | sprintf("%024s", decbin(hexdec(str_replace(" ", "", $currentAlarm)))), |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
39 | -1, |
||
40 | PREG_SPLIT_NO_EMPTY |
||
41 | ); |
||
42 | |||
43 | $alarmDescr = [ |
||
44 | 'input signal high', |
||
45 | 'input signal low', |
||
46 | 'output bias high', |
||
47 | 'output bias low', |
||
48 | 'output signal high', |
||
49 | 'output signal low', |
||
50 | 'lane laser temp high', |
||
51 | 'lane laster temp low', |
||
52 | ]; |
||
53 | |||
54 | $descr = []; |
||
55 | $index = 0; |
||
56 | foreach ($alarmBin as $syntax) { |
||
57 | if ($syntax == "1") { |
||
58 | $descr[$index] = $alarmDescr[$index]; |
||
59 | } |
||
60 | $index++; |
||
61 | } |
||
62 | $message = implode(', ', $descr); |
||
63 | return $message; |
||
64 | } |
||
65 | } |
||
66 |