forked from dfex/DFEXjunoscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-bgp-neat.slax
41 lines (36 loc) · 1.33 KB
/
show-bgp-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
/* show-bgp-neat.slax
* September 23 2014
* Version 1.3
* Ben Dale - ben.dale@gmail.com
*
* Neaten up "show bgp summary" to one neighbour per line
* Props to Phil Shafer (phil@juniper.net) for much neater, backwards compatible prefix summing
*/
version 1.0;
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 = "%-35s %-11s %-13s %18s %10s %10s %10s %-5s";
<output> jcs:printf($output-format, "Peer", "AS", "State", "Duration", "Active", "Received", "Accepted", "Description");
/* Get a list of all peers */
var $show-bgp-summary = {
<command> "show bgp summary";
}
var $neighbour-list = jcs:invoke( $show-bgp-summary );
/* Loop through each peer results summing prefix types */
for-each ($neighbour-list/bgp-peer) {
<output> jcs:printf($output-format,
peer-address,
peer-as,
peer-state,
elapsed-time,
sum(bgp-rib/active-prefix-count),
sum(bgp-rib/received-prefix-count),
sum(bgp-rib/accepted-prefix-count),
description);
}
}
}