forked from dfex/DFEXjunoscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-bgp-adv-route.slax
46 lines (41 loc) · 1.29 KB
/
show-bgp-adv-route.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
/* show-bgp-adv-route.slax
* October 1 2014
* Version 1.0
* Ben Dale - [email protected]
*
* Show all BGP peers a prefix is advertised to
*
*/
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";
param $prefix;
match / {
<op-script-results> {
var $connect = jcs:open();
var $bgp-summary = <get-bgp-summary-information>;
var $bgp-summary-result = jcs:execute($connect, $bgp-summary);
var $output-format = "%-11s%-35s%-35s";
<output> jcs:printf($output-format, "Peer AS", "Peer IP", "Aggregate Prefix");
for-each ($bgp-summary-result/bgp-peer) {
call get-advertised($connect, $peer-ip = peer-address, $peer-as = peer-as);
}
}
}
template get-advertised ($connect, $peer-ip, $peer-as) {
var $gri = <get-route-information> {
<destination> $prefix;
<advertising-protocol-name> "bgp";
<neighbor> $peer-ip;
}
var $gri-result = jcs:execute($connect, $gri);
var $output-format = "%-11s%-35s%-35s";
var $rt-list := $gri-result/route-table/rt;
if ($rt-list) {
for-each ($rt-list/rt-entry) {
<output> jcs:printf($output-format, $peer-as, $peer-ip, ../rt-destination);
}
}
}