Issues (2963)

includes/html/pages/device/routing/mpls.inc.php (1 issue)

1
<?php
2
3
print_optionbar_start();
4
5
$link_array = [
6
    'page'   => 'device',
7
    'device' => $device['device_id'],
8
    'tab'    => 'routing',
9
    'proto'  => 'mpls',
10
];
11
12
if (! isset($vars['view'])) {
13
    $vars['view'] = 'lsp';
14
}
15
16
echo '<span style="font-weight: bold;">MPLS</span> &#187; ';
17
18
if ($vars['view'] == 'lsp') {
19
    echo "<span class='pagemenu-selected'>";
20
}
21
22
echo generate_link('LSPs', $link_array, ['view' => 'lsp']);
23
if ($vars['view'] == 'lsp') {
24
    echo '</span>';
25
}
26
27
echo ' | ';
28
29
if ($vars['view'] == 'paths') {
30
    echo "<span class='pagemenu-selected'>";
31
}
32
33
echo generate_link('Paths', $link_array, ['view' => 'paths']);
34
if ($vars['view'] == 'paths') {
35
    echo '</span>';
36
}
37
38
echo ' | ';
39
40
if ($vars['view'] == 'sdps') {
41
    echo "<span class='pagemenu-selected'>";
42
}
43
44
echo generate_link('SDPs', $link_array, ['view' => 'sdps']);
45
if ($vars['view'] == 'sdps') {
46
    echo '</span>';
47
}
48
49
echo ' | ';
50
51
if ($vars['view'] == 'sdpbinds') {
52
    echo "<span class='pagemenu-selected'>";
53
}
54
55
echo generate_link('SDP binds', $link_array, ['view' => 'sdpbinds']);
56
if ($vars['view'] == 'sdpbinds') {
57
    echo '</span>';
58
}
59
60
echo ' | ';
61
62
if ($vars['view'] == 'services') {
63
    echo "<span class='pagemenu-selected'>";
64
}
65
66
echo generate_link('Services', $link_array, ['view' => 'services']);
67
if ($vars['view'] == 'services') {
68
    echo '</span>';
69
}
70
71
echo ' | ';
72
73
if ($vars['view'] == 'saps') {
74
    echo "<span class='pagemenu-selected'>";
75
}
76
77
echo generate_link('SAPs', $link_array, ['view' => 'saps']);
78
if ($vars['view'] == 'saps') {
79
    echo '</span>';
80
}
81
82
print_optionbar_end();
83
84
echo '<div id="content">
85
    <table  border="0" cellspacing="0" cellpadding="5" width="100%">';
86
if ($vars['view'] == 'lsp') {
87
    echo '<tr><th><a title="Administrative name for this Labeled Switch Path">Name</a></th>
88
        <th><a title="Specifies the destination address of this LSP">Destination</a></th>
89
        <th><a title="Virtual Routing Instance">VRF</a></th>
90
        <th><a title="The desired administrative state for this LSP.">Admin State</a></th>
91
        <th><a title="The current operational state of this LSP.">Oper State</a></th>
92
        <th><a title="The sysUpTime when this LSP was last modified.">Last Change at</a></th>
93
        <th><a title="The number of state transitions (up -> down and down -> up) this LSP has undergone.">Transitions</a></th>
94
        <th><a title="The time since the last transition (up -> down and down -> up) occurred on this LSP.">Last Transition</a></th>
95
        <th><a title="The number of paths configured for this LSP / The number of standby paths configured for this LSP / The number of operational paths for this LSP. This includes the path currently active, as well as operational standby paths.">Paths</br>Conf / Stby / Oper</a></th>
96
        <th><a title="The value specifies whether the label value is statically or dynamically assigned or whether the LSP will be used exclusively for bypass protection.">Type</a></th>
97
        <th><a title="When the value of FRR is true, fast reroute is enabled.  A pre-computed detour LSP is created from each node in the primary path of this LSP.  In case of a failure of a link or LSP between two nodes, traffic is immediately rerouted on the pre-computed detour LSP thus avoiding packet loss.">FRR</a></th>
98
        <th><a title="The percentage up time is calculated by (LSP up time / LSP age * 100 %).">Availability</br>%</a></th>
99
        </tr>';
100
101
    $i = 0;
102
103
    foreach (dbFetchRows('SELECT *, `vrf_name` FROM `mpls_lsps` AS l, `vrfs` AS v WHERE `l`.`vrf_oid` = `v`.`vrf_oid` AND `l`.`device_id` = `v`.`device_id` AND `l`.`device_id` = ?  ORDER BY `l`.`mplsLspName`', [$device['device_id']]) as $lsp) {
104
        if (! is_integer($i / 2)) {
105
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
106
        } else {
107
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
108
        }
109
110
        $adminstate_status_color = $operstate_status_color = $path_status_color = 'default';
111
112
        if ($lsp['mplsLspAdminState'] == 'inService') {
113
            $adminstate_status_color = 'success';
114
        }
115
        if ($lsp['mplsLspOperState'] == 'inService') {
116
            $operstate_status_color = 'success';
117
        } elseif ($lsp['mplsLspAdminState'] == 'inService' && $lsp['mplsLspOperState'] == 'outOfService') {
118
            $operstate_status_color = 'danger';
119
        }
120
        if ($lsp['mplsLspConfiguredPaths'] + $lsp['mplsLspStandbyPaths'] == $lsp['mplsLspOperationalPaths']) {
121
            $path_status_color = 'success';
122
        } elseif ($lsp['mplsLspOperationalPaths'] == '0') {
123
            $path_status_color = 'danger';
124
        } elseif ($lsp['mplsLspConfiguredPaths'] + $lsp['mplsLspStandbyPaths'] > $lsp['mplsLspOperationalPaths']) {
125
            $path_status_color = 'warning';
126
        }
127
128
        $avail = round($lsp['mplsLspPrimaryTimeUp'] / $lsp['mplsLspAge'] * 100, 5);
129
130
        $host = @dbFetchRow('SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', [$lsp['mplsLspToAddr']]);
131
        $destination = $lsp['mplsLspToAddr'];
132
        if (is_array($host)) {
133
            $destination = generate_device_link($host, 0, ['tab' => 'routing', 'proto' => 'mpls', 'view' => 'lsp']);
134
        }
135
136
        echo "<tr bgcolor=$bg_colour>
137
            <td>" . $lsp['mplsLspName'] . '</td>
138
            <td>' . $destination . '</td>
139
            <td>' . $lsp['vrf_name'] . '</td>
140
            <td><span class="label label-' . $adminstate_status_color . '">' . $lsp['mplsLspAdminState'] . '</td>
141
            <td><span class="label label-' . $operstate_status_color . '">' . $lsp['mplsLspOperState'] . '</td>
142
            <td>' . \LibreNMS\Util\Time::formatInterval($lsp['mplsLspLastChange']) . '</td>
143
            <td>' . $lsp['mplsLspTransitions'] . '</td>
144
            <td>' . \LibreNMS\Util\Time::formatInterval($lsp['mplsLspLastTransition']) . '</td>
145
            <td><span class="label label-' . $path_status_color . '">' . $lsp['mplsLspConfiguredPaths'] . '      /     ' . $lsp['mplsLspStandbyPaths'] . ' / ' . $lsp['mplsLspOperationalPaths'] . '</td>
146
            <td>' . $lsp['mplsLspType'] . '</td>
147
            <td>' . $lsp['mplsLspFastReroute'] . '</td>
148
            <td>' . $avail . '</td>';
149
        echo '</tr>';
150
151
        $i++;
152
    }
153
    echo '</table></div>';
154
} // endif lsp view
155
156
if ($vars['view'] == 'paths') {
157
    echo '<tr><th>&nbsp;</th>
158
        <th><a title="Administrative name for LSP this path belongs to">LSP Name</a></th>
159
        <th><a title="The OID index of this path">Index</a></th>
160
        <th><a title="This variable is an enum that represents the role this path is taking within this LSP.">Type</a></th>
161
        <th><a title="The desired administrative state for this LSP Path.">Admin State</a></th>
162
        <th><a title="The current operational state of this LSP Path.">Oper State</a></th>
163
        <th><a title="The sysUpTime when this LSP Path was last modified.">Last Change at</a></th>
164
        <th><a title="The number of transitions that have occurred for this LSP.">Transitions</a></th>
165
        <th><a title="This value specifies the amount of bandwidth in megabits per seconds (Mbps) to be reserved for this LSP path. A value of zero (0) indicates that no bandwidth is reserved.">Bandwidth</a></th>
166
        <th><a title="When make-before-break functionality for the LSP is enabled and if the path bandwidth is changed, the resources allocated to the existing LSP paths will not be released until a new path with the new bandwidth settings has been established. While a new path is being signaled, the administrative value and the operational values of the path bandwidth may differ.">Oper BW</a></th>
167
        <th><a title="The current working state of this path within this LSP.">State</a></th>
168
        <th><a title="This indicates the reason code for LSP path failure. A value of 0 indicates that no failure has occurred.">Failcode</a></th>
169
        <th><a title="This indicates the name of the node in the LSP path at which the LSP path failed.">Fail Node</a></th>
170
        <th><a title="This indicates the cost of the traffic engineered path returned by the IGP.">Metric</a></th>
171
        <th><a title="This indicates the operational metric for the LSP path.">Oper Metric</a></th>
172
        </tr>';
173
174
    $i = 0;
175
176
    foreach (dbFetchRows('SELECT *, `mplsLspName` FROM `mpls_lsp_paths` AS `p`, `mpls_lsps` AS `l` WHERE `p`.`lsp_id` = `l`.`lsp_id` AND `p`.`device_id` = ?  ORDER BY `l`.`mplsLspName`', [$device['device_id']]) as $path) {
177
        if (! is_integer($i / 2)) {
178
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
179
        } else {
180
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
181
        }
182
183
        $adminstate_status_color = $operstate_status_color = 'default';
184
        $failcode_status_color = 'warning';
185
186
        if ($path['mplsLspPathAdminState'] == 'inService') {
187
            $adminstate_status_color = 'success';
188
        }
189
        if ($path['mplsLspPathFailCode'] == 'noError') {
190
            $failcode_status_color = 'success';
191
        }
192
        if ($path['mplsLspPathOperState'] == 'inService') {
193
            $operstate_status_color = 'success';
194
        } elseif ($path['mplsLspPathAdminState'] == 'inService' && $path['mplsLspPathOperState'] == 'outOfService') {
195
            $operstate_status_color = 'danger';
196
        }
197
198
        $host = @dbFetchRow('SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', [$path['mplsLspPathFailNodeAddr']]);
199
        $destination = $path['mplsLspPathFailNodeAddr'];
200
        if (is_array($host)) {
201
            $destination = generate_device_link($host, 0, ['tab' => 'routing', 'proto' => 'mpls']);
202
        }
203
        echo '<tr data-toggle="collapse" data-target="#path-map' . $i . '" class="accordion-toggle" bgcolor="' . $bg_colour . '">
204
            <td><button class="btn btn-default btn-xs"><span class="fa fa-plus"></span></button></td>
205
            <td>' . $path['mplsLspName'] . '</td>
206
            <td>' . $path['path_oid'] . '</td>
207
            <td>' . $path['mplsLspPathType'] . '</td>
208
            <td><span class="label label-' . $adminstate_status_color . '">' . $path['mplsLspPathAdminState'] . '</td>
209
            <td><span class="label label-' . $operstate_status_color . '">' . $path['mplsLspPathOperState'] . '</td>
210
            <td>' . \LibreNMS\Util\Time::formatInterval($path['mplsLspPathLastChange']) . '</td>
211
            <td>' . $path['mplsLspPathTransitionCount'] . '</td>
212
            <td>' . $path['mplsLspPathBandwidth'] . '</td>
213
            <td>' . $path['mplsLspPathOperBandwidth'] . '</td>
214
            <td>' . $path['mplsLspPathState'] . '</td>
215
            <td><span class="label label-' . $failcode_status_color . '">' . $path['mplsLspPathFailCode'] . '</td>
216
            <td>' . $destination . '</td>
217
            <td>' . $path['mplsLspPathMetric'] . '</td>
218
            <td>' . $path['mplsLspPathOperMetric'] . '</td>';
219
        echo '</tr>';
220
        echo '<tr><td colspan="12" class="hiddenRow">';
221
        echo '<div class="accordian-body collapse" id="path-map' . $i . '">';
222
        // FIXME include only on expanded data-toggle
223
        include 'includes/html/pages/routing/mpls-path-map.inc.php';
224
        echo '</div>
225
             </td>
226
             </tr>';
227
228
        $i++;
229
    }
230
    echo '</table></div>';
231
} // end paths view
232
233
if ($vars['view'] == 'sdps') {
234
    echo '<th><a title="Service Distribution Point identifier">SDP Id</a></th>
235
        <th><a title="The value of destination object specifies the device name of the remote end of the tunnel defined by this SDP">Destination</a></th>
236
        <th><a title="This object specifies the type of delivery used by this SDP">Type</a></th>
237
        <th><a title="The value of sdpActiveLspType indicates the type of LSP that is currently active on this SDP. For sdpDelivery gre, the value is always not-applicable. For sdpDelivery mpls, the values can be rsvp, ldp, mplsTp, srIsis, srOspf, srTeLsp, fpe, bgp or none.">LSP Type</a></th>
238
        <th><a title="Generic information about this SDP">Description</a></th>
239
        <th><a title="The desired administrative state for this SDP">Admin State</a></th>
240
        <th><a title="The current operational state of this SDP">Oper State</a></th>
241
        <th><a title="This object specifies the desired largest service frame size (in octets) that can be transmitted through this SDP to the far-end ESR, without requiring the packet to be fragmented. The default value of zero indicates that the path MTU should be computed dynamically from the corresponding MTU of the tunnel.">Admin MTU</a></th>
242
        <th><a title="This object indicates the actual largest service frame size (in octets) that can be transmitted through this SDP to the far-end ESR, without requiring the packet to be fragmented. In order to be able to bind this SDP to a given service, the value of this object minus the control word size (if applicable) must be equal to or larger than the MTU of the service, as defined by its svcMtu.">Oper MTU</a></th>
243
        <th><a title="The value of sysUpTime at the time of the most recent management-initiated change to this SDP.">Last Mgmt Change at</a></th>
244
        <th><a title="The value of sysUpTime at the time of the most recent operating status change to this SDP.">Last Status Change at</a></th>
245
        </tr>';
246
247
    $i = 0;
248
249
    foreach (dbFetchRows('SELECT * FROM `mpls_sdps` WHERE `device_id` = ? ORDER BY `sdp_oid`', [$device['device_id']]) as $sdp) {
250
        if (! is_integer($i / 2)) {
251
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
252
        } else {
253
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
254
        }
255
256
        $adminstate_status_color = $operstate_status_color = 'default';
257
        $failcode_status_color = 'warning';
258
259
        if ($sdp['sdpAdminStatus'] == 'up') {
260
            $adminstate_status_color = 'success';
261
        }
262
        if ($sdp['sdpOperStatus'] == 'up') {
263
            $operstate_status_color = 'success';
264
        } elseif ($sdp['sdpAdminStatus'] == 'up' && $sdp['sdpOperStatus'] == 'down') {
265
            $operstate_status_color = 'danger';
266
        }
267
268
        $host = @dbFetchRow('SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', [$sdp['sdpFarEndInetAddress']]);
269
        $destination = $sdp['sdpFarEndInetAddress'];
270
        if (is_array($host)) {
271
            $destination = generate_device_link($host, 0, ['tab' => 'routing', 'proto' => 'mpls', 'view' => 'sdps']);
272
        }
273
        echo "<tr bgcolor=$bg_colour>
274
            <td>" . $sdp['sdp_oid'] . '</td>
275
            <td>' . $destination . '</td>
276
            <td>' . $sdp['sdpDelivery'] . '</td>
277
            <td>' . $sdp['sdpActiveLspType'] . '</td>
278
            <td>' . $sdp['sdpDescription'] . '</td>
279
            <td><span class="label label-' . $adminstate_status_color . '">' . $sdp['sdpAdminStatus'] . '</td>
280
            <td><span class="label label-' . $operstate_status_color . '">' . $sdp['sdpOperStatus'] . '</td>
281
            <td>' . $sdp['sdpAdminPathMtu'] . '</td>
282
            <td>' . $sdp['sdpOperPathMtu'] . '</td>
283
            <td>' . \LibreNMS\Util\Time::formatInterval($sdp['sdpLastMgmtChange']) . '</td>
284
            <td>' . \LibreNMS\Util\Time::formatInterval($sdp['sdpLastStatusChange']) . '</td>';
285
        echo '</tr>';
286
287
        $i++;
288
    }
289
    echo '</table></div>';
290
} // end sdps view
291
292
if ($vars['view'] == 'sdpbinds') {
293
    echo '<th><a title="The value of this object specifies the Service identifier. This value should be unique within the service domain.">Service Id</a></th>
294
        <th><a title="SDP Binding identifier. SDP identifier : Service identifier">SDP Bind Id</a></th>
295
        <th><a title="This object specifies whether this Service SDP binding is a spoke or a mesh.">Bind Type</a></th>
296
        <th><a title="The value of VC Type is an enumerated integer that specifies the type of virtual circuit (VC) associated with the SDP binding">VC Type</a></th>
297
        <th><a title="The desired state of this Service-SDP binding.">Admin State</a></th>
298
        <th><a title="The value of sdpBindOperStatus indicates the operating status of this Service-SDP binding.
299
up: The Service-SDP binding is operational.
300
noEgressLabel: The ingress label is available but the egress one is missing.
301
noIngressLabel:The egress label is available but the ingress one is not.
302
noLabels: Both the ingress and the egress labels are missing.
303
down: The binding is administratively down.
304
svcMtuMismatch: Both labels are available, but a service  MTU mismatch was detected between the local and the far-end devices.
305
sdpPathMtuTooSmall: The operating path MTU of the corresponding SDP minus the size of the SDP Bind control word (if applicable) is smaller than the service MTU.
306
sdpNotReady: The SDPs signaling session is down.
307
sdpDown: The SDP is not operationally up.
308
sapDown: The SAP associated with the service is down.">Oper State</a></th>
309
        <th><a title="The value of sysUpTime at the time of the most recent management-initiated change to this Service-SDP binding.">Last Mgmt Change at</a></th>
310
        <th><a title="The value of the object sdpBindLastStatusChange indicates the value of sysUpTime at the time of the most recent operating status change to this SDP Bind.">Last Status Change at</a></th>
311
        <th><a title="SDP Bind ingress forwarded packets">Ing Fwd Packets</a></th>
312
        <th><a title="SDP Bind ingress forwarded octets">Ing Fwd Octets</a></th>
313
        <th><a title="SDP Bind egress forwarded packets">Egr Fwd Packets</a></th>
314
        <th><a title="SDP Bind egress forwarded octets">Egr Fwd Octets</a></th>
315
        </tr>';
316
317
    $i = 0;
318
319
    foreach (dbFetchRows('SELECT b.*, s.svc_oid AS svcId FROM `mpls_sdp_binds` AS b LEFT JOIN `mpls_services` AS s ON `b`.`svc_id` = `s`.`svc_id` WHERE `b`.`device_id` = ? ORDER BY `sdp_oid`, `svc_oid`', [$device['device_id']]) as $sdpbind) {
320
        if (! is_integer($i / 2)) {
321
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
322
        } else {
323
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
324
        }
325
326
        $adminstate_status_color = $operstate_status_color = 'default';
327
        $failcode_status_color = 'warning';
328
329
        if ($sdpbind['sdpBindAdminStatus'] == 'up') {
330
            $adminstate_status_color = 'success';
331
        }
332
        if ($sdpbind['sdpBindAdminStatus'] == 'up' && $sdpbind['sdpBindOperStatus'] == 'up') {
333
            $operstate_status_color = 'success';
334
        } elseif ($sdpbind['sdpBindAdminStatus'] == 'up' && $sdpbind['sdpBindOperStatus'] == 'down') {
335
            $operstate_status_color = 'danger';
336
        }
337
338
        echo "<tr bgcolor=$bg_colour>
339
            <td>" . $sdpbind['svcId'] . '</td>
340
            <td>' . $sdpbind['sdp_oid'] . ':' . $sdpbind['svc_oid'] . '</td>
341
            <td>' . $sdpbind['sdpBindType'] . '</td>
342
            <td>' . $sdpbind['sdpBindVcType'] . '</td>
343
            <td><span class="label label-' . $adminstate_status_color . '">' . $sdpbind['sdpBindAdminStatus'] . '</td>
344
            <td><span class="label label-' . $operstate_status_color . '">' . $sdpbind['sdpBindOperStatus'] . '</td>
345
            <td>' . \LibreNMS\Util\Time::formatInterval($sdpbind['sdpBindLastMgmtChange']) . '</td>
346
            <td>' . \LibreNMS\Util\Time::formatInterval($sdpbind['sdpBindLastStatusChange']) . '</td>
347
            <td>' . $sdpbind['sdpBindBaseStatsIngFwdPackets'] . '</td>
348
            <td>' . $sdpbind['sdpBindBaseStatsIngFwdOctets'] . '</td>
349
            <td>' . $sdpbind['sdpBindBaseStatsEgrFwdPackets'] . '</td>
350
            <td>' . $sdpbind['sdpBindBaseStatsEgrFwdOctets'] . '</td>';
351
        echo '</tr>';
352
353
        $i++;
354
    }
355
    echo '</table></div>';
356
} // end sdpbinds view
357
358
if ($vars['view'] == 'services') {
359
    echo '<th><a title="The value of this object specifies the Service identifier. This value should be unique within the service domain.">Service Id</a></th>
360
        <th><a title="The value of this object specifies the service type: e.g. epipe, tls, etc.">Type</a></th>
361
        <th><a title="The value of this object specifies the ID of the customer who owns this service.">Customer</a></th>
362
        <th><a title="The value of this object specifies the desired state of this service.">Admin Status</a></th>
363
        <th><a title="The value of this object indicates the operating state of this service. The requirements for a service to be operationally up depend on the service type:
364
epipe, apipe, fpipe, ipipe and cpipe services are up when the service is administratively up and either both SAPs or a SAP and a spoke SDP Bind are operationally up.
365
tls services are up when the service is administratively up and either at least one SAP or spoke SDP Bind or one mesh SDP Bind is operationally up.
366
tls service that has vxlan configuration is up when the service is administratively up.
367
ies services are up when the service is administratively up and at least one interface is operationally up.
368
vprn services are up when the service is administratively up however routing functionality is available only when TIMETRA-VRTR-MIB::vRtrOperState is up.">Oper Status</a></th>
369
        <th><a title="The value of the object svcDescription specifiers an optional, generic information about this service.">Description</a></th>
370
        <th><a title="The value of the object svcMtu specifies the largest frame size (in octets) that this service can handle. Setting svcMtu to a value of zero (0), causes the agent to recalculate the default MTU size. The default value of this object depends on the service type: 1514 octets for epipe and tls, 1508 for apipe and fpipe, and 1500 octets for vprn, ipipe and ies, 1514 octets for cpipe.">Service MTU</a></th>
371
        <th><a title="The value of the object svcNumSaps indicates the number of SAPs defined on this service.">Num SAPs</a></th>
372
        <th><a title="The value of of the object svcLastMgmtChange indicates the value of sysUpTime at the time of the most recent management-initiated change to this service.">Last Mgmt Change at</a></th>
373
        <th><a title="The value of the object svcLastStatusChange indicates the value of sysUpTime at the time of the most recent operating status change to his service.">Last Status Change at</a></th>
374
        <th><a title="The value of this object specifies, for a IES or VPRN service the associated virtual router instance where its interfaces are defined. This object has a special significance for the VPRN service as it can be used to associate the service to a specific virtual router instance. If no routing instance is specified or a value of zero (0) is specified, the agent will assign the vRtrID index value that would have been returned by the vRtrNextVRtrID object in the TIMETRA-VRTR-MIB">VRF</a></th>
375
        <th><a title="The value specifies whether the MAC learning process is enabled in this TLS.">MAC Learning</a></th>
376
        <th><a title="The value of the object svcTlsFdbTableSize specifies the maximum number of learned and static entries allowed in the FDB of this service. The maximum value of svcTlsFdbTableSize depends on the platform/chassis mode.">FDB Table Size</a></th>
377
        <th><a title="The value of the object svcTlsFdbNumEntries indicates the current number of entries allocated in the FDB of this service.">FDB Entries</a></th>
378
        <th><a title="The value of the object svcTlsStpAdminStatus specifies the administrative state of the Spanning Tree Protocol instance associated with this service.">STP Admin Status</a></th>
379
        <th><a title="The value of the object svcTlsStpOperStatus indicates the operating status of the Spanning Tree Protocol instance associated with this service.">STP Oper Status</a></th>
380
        </tr>';
381
382
    $i = 0;
383
384
    foreach (dbFetchRows('SELECT s.*, v.vrf_name FROM `mpls_services` AS s LEFT JOIN  `vrfs` AS v ON `s`.`svcVRouterId` = `v`.`vrf_oid` AND `s`.`device_id` = `v`.`device_id` WHERE `s`.`device_id` = ? ORDER BY `svc_oid`', [$device['device_id']]) as $svc) {
385
        if (! is_integer($i / 2)) {
386
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
387
        } else {
388
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
389
        }
390
391
        $adminstate_status_color = $operstate_status_color = 'default';
392
        $failcode_status_color = 'warning';
393
394
        if ($svc['svcAdminStatus'] == 'up') {
395
            $adminstate_status_color = 'success';
396
        }
397
        if ($svc['svcAdminStatus'] == 'up' && $svc['svcOperStatus'] == 'up') {
398
            $operstate_status_color = 'success';
399
        } elseif ($svc['svcAdminStatus'] == 'up' && $svc['svcOperStatus'] == 'down') {
400
            $operstate_status_color = 'danger';
401
        }
402
403
        $fdb_usage_perc = $svc['svcTlsFdbNumEntries'] / $svc['svcTlsFdbTableSize'] * 100;
404
        if ($fdb_usage_perc > 95) {
405
            $fdb_status_color = 'danger';
406
        } elseif ($fdb_usage_perc > 75) {
407
            $fdb_status_color = 'warning';
408
        } else {
409
            $fdb_status_color = 'success';
410
        }
411
412
        echo "<tr bgcolor=$bg_colour>
413
            <td>" . $svc['svc_oid'] . '</td>
414
            <td>' . $svc['svcType'] . '</td>
415
            <td>' . $svc['svcCustId'] . '</td>
416
            <td><span class="label label-' . $adminstate_status_color . '">' . $svc['svcAdminStatus'] . '</td>
417
            <td><span class="label label-' . $operstate_status_color . '">' . $svc['svcOperStatus'] . '</td>
418
            <td>' . $svc['svcDescription'] . '</td>
419
            <td>' . $svc['svcMtu'] . '</td>
420
            <td>' . $svc['svcNumSaps'] . '</td>
421
            <td>' . \LibreNMS\Util\Time::formatInterval($svc['svcLastMgmtChange']) . '</td>
422
            <td>' . \LibreNMS\Util\Time::formatInterval($svc['svcLastStatusChange']) . '</td>
423
            <td>' . $svc['vrf_name'] . '</td>
424
            <td>' . $svc['svcTlsMacLearning'] . '</td>
425
            <td>' . $svc['svcTlsFdbTableSize'] . '</td>
426
            <td><span class="label label-' . $fdb_status_color . '">' . $svc['svcTlsFdbNumEntries'] . '</td>
427
            <td>' . $svc['svcTlsStpAdminStatus'] . '</td>
428
            <td>' . $svc['svcTlsStpOperStatus'] . '</td>';
429
        echo '</tr>';
430
431
        $i++;
432
    }
433
    echo '</table></div>';
434
} // end services view
435
436
if ($vars['view'] == 'saps') {
437
    echo '<th><a title="The value of this object specifies the Service identifier.">Service Id</a></th>
438
        <th><a title="The ID of the access port where this SAP is defined.">SAP Port</a></th>
439
        <th><a title="The value of the label used to identify this SAP on the access port specified by sapPortId.">Encapsulation</a></th>
440
        <th><a title="This object indicates the type of service where this SAP is defined.">Type</a></th>
441
        <th><a title="Generic information about this SAP.">Description</a></th>
442
        <th><a title="The desired state of this SAP.">Admin Status</a></th>
443
        <th><a title="The value of the object sapOperStatus indicates the operating state of this SAP.">Oper Satatus</a></th>
444
        <th><a title="The value of sysUpTime at the time of the most recent management-initiated change to this SAP.">Last Mgmt Change at</a></th>
445
        <th><a title="The value of sysUpTime at the time of the most recent operating status change to this SAP.">Last Oper Change at</a></th>
446
        </tr>';
447
448
    $i = 0;
449
450
    foreach (dbFetchRows('SELECT * FROM `mpls_saps` WHERE `device_id` = ? ORDER BY `device_id`, `svc_oid`, `sapPortId`, `sapEncapValue`', [$device['device_id']]) as $sap) {
451
        $port = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifName` = ?', [$sap['device_id'], $sap['ifName']]);
452
        $port = cleanPort($port);
453
454
        if (! is_integer($i / 2)) {
455
            $bg_colour = \LibreNMS\Config::get('list_colour.even');
456
        } else {
457
            $bg_colour = \LibreNMS\Config::get('list_colour.odd');
458
        }
459
460
        $adminstate_status_color = $operstate_status_color = 'default';
461
        $failcode_status_color = 'warning';
462
463
        if ($sap['sapAdminStatus'] == 'up') {
464
            $adminstate_status_color = 'success';
465
        }
466
        if ($sap['sapAdminStatus'] == 'up' && $sap['sapOperStatus'] == 'up') {
467
            $operstate_status_color = 'success';
468
        } elseif ($sap['sapAdminStatus'] == 'up' && $sap['sapOperStatus'] == 'down') {
469
            $operstate_status_color = 'danger';
470
        }
471
472
        echo "<tr bgcolor=$bg_colour>" . '
473
            <td>' . generate_sap_url($sap, $sap['svc_oid']) . '</td>
474
            <td>' . generate_port_link($port) . '</td>
0 ignored issues
show
Are you sure generate_port_link($port) of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

474
            <td>' . /** @scrutinizer ignore-type */ generate_port_link($port) . '</td>
Loading history...
475
            <td>' . $sap['sapEncapValue'] . '</td>
476
            <td>' . $sap['sapType'] . '</td>
477
            <td>' . $sap['sapDescription'] . '</td>
478
            <td><span class="label label-' . $adminstate_status_color . '">' . $sap['sapAdminStatus'] . '</td>
479
            <td><span class="label label-' . $operstate_status_color . '">' . $sap['sapOperStatus'] . '</td>
480
            <td>' . \LibreNMS\Util\Time::formatInterval($sap['sapLastMgmtChange']) . '</td>
481
            <td>' . \LibreNMS\Util\Time::formatInterval($sap['sapLastStatusChange']) . '</td>';
482
        echo '</tr>';
483
484
        $i++;
485
    }
486
    echo '</table></div>';
487
} // end sap view
488