1 | <?php |
||
2 | /* |
||
3 | * LibreNMS discovery module for Eltex-MES SFP Voltage |
||
4 | * |
||
5 | * This program is free software: you can redistribute it and/or modify |
||
6 | * it under the terms of the GNU General Public License as published by |
||
7 | * the Free Software Foundation, either version 3 of the License, or |
||
8 | * (at your option) any later version. |
||
9 | * |
||
10 | * This program is distributed in the hope that it will be useful, |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
13 | * GNU General Public License for more details. |
||
14 | * |
||
15 | * You should have received a copy of the GNU General Public License |
||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
17 | * |
||
18 | * @package LibreNMS |
||
19 | * @link https://www.librenms.org |
||
20 | * |
||
21 | * @author Peca Nesovanovic <[email protected]> |
||
22 | */ |
||
23 | |||
24 | $low_limit = $low_warn_limit = 3; |
||
25 | $high_warn_limit = $high_limit = 4; |
||
26 | $divisor = 1000000; |
||
27 | |||
28 | $oids = snmp_walk($device, '1.3.6.1.4.1.89.90.1.2.1.3', '-Osqn', ''); |
||
29 | $oids = trim($oids); |
||
30 | |||
31 | if ($oids) { |
||
32 | echo "Eltex-MES Voltage:\n"; |
||
33 | |||
34 | foreach (explode("\n", $oids) as $data) { |
||
35 | if ($data) { |
||
36 | print_r($data); |
||
37 | echo "\n"; |
||
38 | $split = trim(explode(' ', $data)[0]); |
||
39 | $value = trim(explode(' ', $data)[1]); |
||
40 | $ifIndex = explode('.', $split)[13]; |
||
41 | $type = explode('.', $split)[14]; |
||
42 | |||
43 | // type6 = voltage |
||
44 | if ($type == 6) { |
||
45 | $descr_oid = '1.0.8802.1.1.2.1.3.7.1.3.' . $ifIndex; |
||
46 | $descr = trim(snmp_get($device, $descr_oid, '-Oqv', ''), '"'); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
47 | $value = $value / $divisor; |
||
48 | discover_sensor($valid['sensor'], 'voltage', $device, $split, 'SfpVolt' . $ifIndex, 'eltex-mes', 'SfpVolt-' . $descr, $divisor, '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 |