1 | <?php |
||
2 | |||
3 | /* |
||
4 | * Try to discover any MEF Links |
||
5 | */ |
||
6 | |||
7 | /* |
||
8 | * Variable to hold the discovered MEF Links. |
||
9 | */ |
||
10 | |||
11 | $mef_list = []; |
||
12 | |||
13 | /* |
||
14 | * Fetch information about MEF Links. |
||
15 | */ |
||
16 | |||
17 | $oids = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', $oids, 'MEF-UNI-EVC-MIB'); |
||
18 | |||
19 | echo 'MEF : '; |
||
20 | foreach ($oids as $index => $entry) { |
||
21 | $mefIdent = $entry['mefServiceEvcCfgIdentifier']; |
||
22 | $mefType = $entry['mefServiceEvcCfgServiceType']; |
||
23 | $mefMtu = $entry['mefServiceEvcCfgMtuSize']; |
||
24 | $mefAdmState = $entry['mefServiceEvcCfgAdminState']; |
||
25 | $mefRowState = $entry['mefServiceEvcCfgRowStatus']; |
||
26 | |||
27 | /* |
||
28 | * Coriant MEF-EVC is quite strange, MTU is sometime set to 0 setting it to "strange" default value |
||
29 | * According to Coriant this should be fixed in Nov 2017. |
||
30 | */ |
||
31 | if (($mefMtu == 0) && ($device['os'] == 'coriant')) { |
||
32 | $mefMtu = 1600; |
||
33 | } |
||
34 | |||
35 | /* |
||
36 | * Check if the MEF is already known for this host |
||
37 | */ |
||
38 | if (dbFetchCell('SELECT COUNT(id) FROM `mefinfo` WHERE `device_id` = ? AND `mefID` = ?', [$device['device_id'], $index]) == 0) { |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
39 | $mefid = dbInsert(['device_id' => $device['device_id'], 'mefID' => $index, 'mefType' => $mefType, 'mefIdent' => $mefIdent, 'mefMTU' => $mefMtu, 'mefAdmState' => $mefAdmState, 'mefRowState' => $mefRowState], 'mefinfo'); |
||
40 | log_event('MEF link: ' . $mefIdent . ' (' . $index . ') Discovered', $device, 'system', 2); |
||
41 | echo '+'; |
||
42 | } else { |
||
43 | echo '.'; |
||
44 | } |
||
45 | /* |
||
46 | * Save the discovered MEF Link |
||
47 | */ |
||
48 | $mef_list[] = $index; |
||
49 | } |
||
50 | |||
51 | /* |
||
52 | * Get a list of all the known MEF Links for this host |
||
53 | */ |
||
54 | |||
55 | $sql = "SELECT id, mefID, mefIdent FROM mefinfo WHERE device_id = '" . $device['device_id'] . "'"; |
||
56 | foreach (dbFetchRows($sql) as $db_mef) { |
||
57 | /* |
||
58 | * Delete the MEF Link that are removed from the host. |
||
59 | */ |
||
60 | if (! in_array($db_mef['mefID'], $mef_list)) { |
||
61 | dbDelete('mefinfo', '`id` = ?', [$db_mef['id']]); |
||
62 | log_event('MEF link: ' . $db_mef['mefIdent'] . ' Removed', $device, 'system', 3); |
||
63 | echo '-'; |
||
64 | } |
||
65 | } |
||
66 | /* |
||
67 | * Finished MEF information |
||
68 | */ |
||
69 | unset($mef_list, $oids, $db_mef); |
||
70 | echo PHP_EOL; |
||
71 |