forked from dfex/DFEXjunoscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-lldp-neat.slax
39 lines (35 loc) · 1.45 KB
/
show-lldp-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
/* show-lldp-neat.slax
* March 27 2015
* Version 1.0
* Ben Dale - ben.dale@gmail.com
*
* Improves show lldp neighbor to present the Port ID as well as the Port Description
*/
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 $connect = jcs:open();
var $output-format = "%-18s%-15s%-17s%-18s%-30s";
<output> jcs:printf($output-format, "Local Interface", "Local Parent", "Remote Hostname", "Remote Interface", "Remote Description");
var $rpc-lldp-neighbors = {
<command> "show lldp neighbors";
}
var $res-lldp-neighbors = jcs:execute($connect, $rpc-lldp-neighbors);
for-each ($res-lldp-neighbors/lldp-neighbor-information) {
var $rpc-lldp-interface = {
<command> "show lldp neighbor interface " _ lldp-local-interface;
}
var $res-lldp-interface = jcs:invoke( $rpc-lldp-interface );
<output> jcs:printf($output-format,
$res-lldp-interface/lldp-neighbor-information/lldp-local-interface,
$res-lldp-interface/lldp-neighbor-information/lldp-local-parent-interface-name,
$res-lldp-interface/lldp-neighbor-information/lldp-remote-system-name,
$res-lldp-interface/lldp-neighbor-information/lldp-remote-port-id,
$res-lldp-interface/lldp-neighbor-information/lldp-remote-port-description);
}
}
}