1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Timos.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
|
|
|
* @package LibreNMS |
21
|
|
|
* @link http://librenms.org |
22
|
|
|
* @copyright 2019 Vitali Kari |
23
|
|
|
* @copyright 2019 Tony Murray |
24
|
|
|
* @author Vitali Kari <[email protected]> |
25
|
|
|
* @author Tony Murray <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
namespace LibreNMS\OS; |
29
|
|
|
|
30
|
|
|
use App\Models\MplsLsp; |
31
|
|
|
use App\Models\MplsLspPath; |
32
|
|
|
use Illuminate\Support\Collection; |
33
|
|
|
use LibreNMS\Interfaces\Discovery\MplsDiscovery; |
34
|
|
|
use LibreNMS\Interfaces\Polling\MplsPolling; |
35
|
|
|
use LibreNMS\OS; |
36
|
|
|
|
37
|
|
|
class Timos extends OS implements MplsDiscovery, MplsPolling |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @return Collection MplsLsp objects |
41
|
|
|
*/ |
42
|
|
|
public function discoverMplsLsps() |
43
|
|
|
{ |
44
|
|
|
$mplsLspCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspTable', [], 'TIMETRA-MPLS-MIB', 'nokia'); |
45
|
|
|
if (!empty($mplsLspCache)) { |
46
|
|
|
$mplsLspCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspLastChange', $mplsLspCache, 'TIMETRA-MPLS-MIB', 'nokia', '-OQUst'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$lsps = collect(); |
50
|
|
|
foreach ($mplsLspCache as $key => $value) { |
51
|
|
|
list($vrf_oid, $lsp_oid) = explode('.', $key); |
52
|
|
|
$lsps->push(new MplsLsp([ |
53
|
|
|
'vrf_oid' => $vrf_oid, |
54
|
|
|
'lsp_oid' => $lsp_oid, |
55
|
|
|
'device_id' => $this->getDeviceId(), |
56
|
|
|
'mplsLspRowStatus' => $value['vRtrMplsLspRowStatus'], |
57
|
|
|
'mplsLspLastChange' => round($value['vRtrMplsLspLastChange'] / 100), |
58
|
|
|
'mplsLspName' => $value['vRtrMplsLspName'], |
59
|
|
|
'mplsLspAdminState' => $value['vRtrMplsLspAdminState'], |
60
|
|
|
'mplsLspOperState' => $value['vRtrMplsLspOperState'], |
61
|
|
|
'mplsLspFromAddr' => $value['vRtrMplsLspFromAddr'], |
62
|
|
|
'mplsLspToAddr' => $value['vRtrMplsLspToAddr'], |
63
|
|
|
'mplsLspType' => $value['vRtrMplsLspType'], |
64
|
|
|
'mplsLspFastReroute' => $value['vRtrMplsLspFastReroute'], |
65
|
|
|
])); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $lsps; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param Collection $lsps collecton of synchronized lsp objects from discoverMplsLsps() |
73
|
|
|
* @return Collection MplsLspPath objects |
74
|
|
|
*/ |
75
|
|
|
public function discoverMplsPaths($lsps) |
76
|
|
|
{ |
77
|
|
|
$mplsPathCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspPathTable', [], 'TIMETRA-MPLS-MIB', 'nokia'); |
78
|
|
|
if (!empty($mplsPathCache)) { |
79
|
|
|
$mplsPathCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspPathLastChange', $mplsPathCache, 'TIMETRA-MPLS-MIB', 'nokia', '-OQUst'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$paths = collect(); |
83
|
|
|
foreach ($mplsPathCache as $key => $value) { |
84
|
|
|
list($vrf_oid, $lsp_oid, $path_oid) = explode('.', $key); |
85
|
|
|
$lsp_id = $lsps->where('lsp_oid', $lsp_oid)->firstWhere('vrf_oid', $vrf_oid)->lsp_id; |
86
|
|
|
$paths->push(new MplsLspPath([ |
87
|
|
|
'lsp_id' => $lsp_id, |
88
|
|
|
'path_oid' => $path_oid, |
89
|
|
|
'device_id' => $this->getDeviceId(), |
90
|
|
|
'mplsLspPathRowStatus' => $value['vRtrMplsLspPathRowStatus'], |
91
|
|
|
'mplsLspPathLastChange' => round($value['vRtrMplsLspPathLastChange'] / 100), |
92
|
|
|
'mplsLspPathType' => $value['vRtrMplsLspPathType'], |
93
|
|
|
'mplsLspPathBandwidth' => $value['vRtrMplsLspPathBandwidth'], |
94
|
|
|
'mplsLspPathOperBandwidth' => $value['vRtrMplsLspPathOperBandwidth'], |
95
|
|
|
'mplsLspPathAdminState' => $value['vRtrMplsLspPathAdminState'], |
96
|
|
|
'mplsLspPathOperState' => $value['vRtrMplsLspPathOperState'], |
97
|
|
|
'mplsLspPathState' => $value['vRtrMplsLspPathState'], |
98
|
|
|
'mplsLspPathFailCode' => $value['vRtrMplsLspPathFailCode'], |
99
|
|
|
'mplsLspPathFailNodeAddr' => $value['vRtrMplsLspPathFailNodeAddr'], |
100
|
|
|
'mplsLspPathMetric' => $value['vRtrMplsLspPathMetric'], |
101
|
|
|
'mplsLspPathOperMetric' => $value['vRtrMplsLspPathOperMetric'], |
102
|
|
|
])); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $paths; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return Collection MplsLsp objects |
111
|
|
|
*/ |
112
|
|
|
public function pollMplsLsps() |
113
|
|
|
{ |
114
|
|
|
$mplsLspCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspTable', [], 'TIMETRA-MPLS-MIB', 'nokia'); |
115
|
|
|
if (!empty($mplsLspCache)) { |
116
|
|
|
$mplsLspCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspLastChange', $mplsLspCache, 'TIMETRA-MPLS-MIB', 'nokia', '-OQUst'); |
117
|
|
|
$mplsLspCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspStatTable', $mplsLspCache, 'TIMETRA-MPLS-MIB', 'nokia'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$lsps = collect(); |
121
|
|
|
foreach ($mplsLspCache as $key => $value) { |
122
|
|
|
list($vrf_oid, $lsp_oid) = explode('.', $key); |
123
|
|
|
$lsps->push(new MplsLsp([ |
124
|
|
|
'vrf_oid' => $vrf_oid, |
125
|
|
|
'lsp_oid' => $lsp_oid, |
126
|
|
|
'device_id' => $this->getDeviceId(), |
127
|
|
|
'mplsLspRowStatus' => $value['vRtrMplsLspRowStatus'], |
128
|
|
|
'mplsLspLastChange' => round($value['vRtrMplsLspLastChange'] / 100), |
129
|
|
|
'mplsLspName' => $value['vRtrMplsLspName'], |
130
|
|
|
'mplsLspAdminState' => $value['vRtrMplsLspAdminState'], |
131
|
|
|
'mplsLspOperState' => $value['vRtrMplsLspOperState'], |
132
|
|
|
'mplsLspFromAddr' => $value['vRtrMplsLspFromAddr'], |
133
|
|
|
'mplsLspToAddr' => $value['vRtrMplsLspToAddr'], |
134
|
|
|
'mplsLspType' => $value['vRtrMplsLspType'], |
135
|
|
|
'mplsLspFastReroute' => $value['vRtrMplsLspFastReroute'], |
136
|
|
|
'mplsLspAge' => abs($value['vRtrMplsLspAge']), |
137
|
|
|
'mplsLspTimeUp' => abs($value['vRtrMplsLspTimeUp']), |
138
|
|
|
'mplsLspTimeDown' => abs($value['vRtrMplsLspTimeDown']), |
139
|
|
|
'mplsLspPrimaryTimeUp' => abs($value['vRtrMplsLspPrimaryTimeUp']), |
140
|
|
|
'mplsLspTransitions' => $value['vRtrMplsLspTransitions'], |
141
|
|
|
'mplsLspLastTransition' => abs(round($value['vRtrMplsLspLastTransition'] / 100)), |
142
|
|
|
'mplsLspConfiguredPaths' => $value['vRtrMplsLspConfiguredPaths'], |
143
|
|
|
'mplsLspStandbyPaths' => $value['vRtrMplsLspStandbyPaths'], |
144
|
|
|
'mplsLspOperationalPaths' => $value['vRtrMplsLspOperationalPaths'], |
145
|
|
|
])); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
return $lsps; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param Collection $lsps collecton of synchronized lsp objects from pollMplsLsps() |
153
|
|
|
* @return Collection MplsLspPath objects |
154
|
|
|
*/ |
155
|
|
|
public function pollMplsPaths($lsps) |
156
|
|
|
{ |
157
|
|
|
$mplsPathCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspPathTable', [], 'TIMETRA-MPLS-MIB', 'nokia'); |
158
|
|
|
if (!empty($mplsPathCache)) { |
159
|
|
|
$mplsPathCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspPathLastChange', $mplsPathCache, 'TIMETRA-MPLS-MIB', 'nokia', '-OQUst'); |
160
|
|
|
$mplsPathCache = snmpwalk_cache_multi_oid($this->getDevice(), 'vRtrMplsLspPathStatTable', $mplsPathCache, 'TIMETRA-MPLS-MIB', 'nokia'); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
$paths = collect(); |
164
|
|
|
foreach ($mplsPathCache as $key => $value) { |
165
|
|
|
list($vrf_oid, $lsp_oid, $path_oid) = explode('.', $key); |
166
|
|
|
$lsp_id = $lsps->where('lsp_oid', $lsp_oid)->firstWhere('vrf_oid', $vrf_oid)->lsp_id; |
167
|
|
|
$paths->push(new MplsLspPath([ |
168
|
|
|
'lsp_id' => $lsp_id, |
169
|
|
|
'path_oid' => $path_oid, |
170
|
|
|
'device_id' => $this->getDeviceId(), |
171
|
|
|
'mplsLspPathRowStatus' => $value['vRtrMplsLspPathRowStatus'], |
172
|
|
|
'mplsLspPathLastChange' => round($value['vRtrMplsLspPathLastChange'] / 100), |
173
|
|
|
'mplsLspPathType' => $value['vRtrMplsLspPathType'], |
174
|
|
|
'mplsLspPathBandwidth' => $value['vRtrMplsLspPathBandwidth'], |
175
|
|
|
'mplsLspPathOperBandwidth' => $value['vRtrMplsLspPathOperBandwidth'], |
176
|
|
|
'mplsLspPathAdminState' => $value['vRtrMplsLspPathAdminState'], |
177
|
|
|
'mplsLspPathOperState' => $value['vRtrMplsLspPathOperState'], |
178
|
|
|
'mplsLspPathState' => $value['vRtrMplsLspPathState'], |
179
|
|
|
'mplsLspPathFailCode' => $value['vRtrMplsLspPathFailCode'], |
180
|
|
|
'mplsLspPathFailNodeAddr' => $value['vRtrMplsLspPathFailNodeAddr'], |
181
|
|
|
'mplsLspPathMetric' => $value['vRtrMplsLspPathMetric'], |
182
|
|
|
'mplsLspPathOperMetric' => $value['vRtrMplsLspPathOperMetric'], |
183
|
|
|
'mplsLspPathTimeUp' => abs($value['vRtrMplsLspPathTimeUp']), |
184
|
|
|
'mplsLspPathTimeDown' => abs($value['vRtrMplsLspPathTimeDown']), |
185
|
|
|
'mplsLspPathTransitionCount' => $value['vRtrMplsLspPathTransitionCount'], |
186
|
|
|
])); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
return $paths; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|