1 | <?php |
||
2 | /** |
||
3 | * Ekinops.php |
||
4 | * |
||
5 | * Ekinops Optical Network |
||
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 <https://www.gnu.org/licenses/>. |
||
19 | * |
||
20 | * @link https://www.librenms.org |
||
21 | * |
||
22 | * @copyright KanREN, Inc 2020 |
||
23 | * @author Heath Barnhart <[email protected]> |
||
24 | */ |
||
25 | |||
26 | namespace LibreNMS\OS; |
||
27 | |||
28 | use App\Models\Device; |
||
29 | use LibreNMS\Interfaces\Discovery\OSDiscovery; |
||
30 | use LibreNMS\OS; |
||
31 | |||
32 | class Ekinops extends OS implements OSDiscovery |
||
33 | { |
||
34 | public function discoverOS(Device $device): void |
||
35 | { |
||
36 | $sysDescr = $device->sysDescr; |
||
37 | $info = explode(',', $sysDescr); |
||
38 | |||
39 | $device->hardware = trim($info[1]); |
||
40 | $device->version = trim($info[2]); |
||
41 | |||
42 | $mgmtCard = snmp_get($this->getDeviceArray(), 'mgnt2RinvHwPlatform.0', '-OQv', 'EKINOPS-MGNT2-MIB'); |
||
43 | $mgmtInfo = self::ekinopsInfo($mgmtCard); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
44 | $device->serial = $mgmtInfo['Serial Number']; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Parses Ekinops inventory returned in a tabular format within a single OID |
||
49 | * |
||
50 | * @param string $ekiInfo |
||
51 | * @return array $inv |
||
52 | */ |
||
53 | public static function ekinopsInfo($ekiInfo) |
||
54 | { |
||
55 | $info = explode("\n", $ekiInfo); |
||
56 | unset($info[0]); |
||
57 | $inv = []; |
||
58 | foreach ($info as $line) { |
||
59 | [$attr, $value] = explode(':', $line); |
||
60 | $attr = trim($attr); |
||
61 | $value = trim($value); |
||
62 | $inv[$attr] = $value; |
||
63 | } |
||
64 | |||
65 | return $inv; |
||
66 | } |
||
67 | } |
||
68 |