forked from dfex/DFEXjunoscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-mpls-lsp-ingress-neat.slax
59 lines (54 loc) · 2.05 KB
/
show-mpls-lsp-ingress-neat.slax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* show-mpls-lsp-ingress-neat.slax
* January 30 2016
* Version 1.0
* Ben Dale - [email protected]
*
* Neaten up "show mpls lsp ingress" to cater for long Path and LSP names
*/
version 1.1;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
match / {
<op-script-results> {
var $output-format = "%-15s %-15s %-5s %2s %-2s %-30s %-30s";
var $show-mpls-lsp-ingress = {
<command> "show mpls lsp ingress";
}
var $ingress-lsp-list = jcs:invoke( $show-mpls-lsp-ingress );
<output> jcs:output($ingress-lsp-list/rsvp-session-data/session-type,
" LSP: ",
$ingress-lsp-list/rsvp-session-data/count,
" sessions");
<output> jcs:printf($output-format, "To", "From", "State", "Rt", "P", "Active Path", "LSP Name");
for-each ($ingress-lsp-list/rsvp-session-data/rsvp-session) {
if (mpls-lsp/is-primary) {
<output> jcs:printf($output-format,
mpls-lsp/destination-address,
mpls-lsp/source-address,
mpls-lsp/lsp-state,
mpls-lsp/route-count,
"*",
mpls-lsp/active-path,
mpls-lsp/name);
}
else {
<output> jcs:printf($output-format,
mpls-lsp/destination-address,
mpls-lsp/source-address,
mpls-lsp/lsp-state,
mpls-lsp/route-count,
" ",
mpls-lsp/active-path,
mpls-lsp/name);
}
}
<output> jcs:output("Total ",
$ingress-lsp-list/rsvp-session-data/display-count,
" displayed, Up ",
$ingress-lsp-list/rsvp-session-data/up-count,
", Down ",
$ingress-lsp-list/rsvp-session-data/down-count);
}
}