[j-nsp] OP script to show descriptions
tim tiriche
tim.tiriche at gmail.com
Mon Jan 16 11:20:57 EST 2012
Thank you very much, Phil !!!!
On Sat, Jan 14, 2012 at 7:05 AM, Phil Shafer <phil at juniper.net> wrote:
> tim tiriche writes:
>>Would anyone have an op script that when executed shows the
>>description of the interface of 'show isis adjancency' or 'show ospf
>>neighbor'
>
> I don't run ISIS in my test lab, but here's a a script I whipped
> up for you that handles OSPF:
>
> user at cli> op test
> Neighbor Interface State Description
> 10.5.10.2 fe-0/0/1.0 Full Link to SJC (10.5.10.2)
> 10.5.13.2 fe-0/0/2.0 Full Link to LAX (10.5.13.2)
> 10.5.12.2 fe-0/3/1.0 Full Link to AUS (10.5.12.2)
>
> IIRC there's a sample script on junos.juniper.net that does "show
> interfaces" with "show interfaces descriptions" merged in, which
> but I did this one from scratch since it was simple enough.
>
> Thanks,
> Phil
>
>
> 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";
>
> var $fmt = "%-16s %-20s %-8s %s";
>
> match / {
> <op-script-results> {
> <top> {
> var $conn = jcs:open();
> var $rpc = <get-interface-information> {
> <descriptions>;
> }
> var $interfaces = jcs:execute($conn, $rpc);
> var $ospf = jcs:execute($conn, "get-ospf-neighbor-information");
>
> <output> jcs:printf($fmt, "Neighbor", "Interface",
> "State", "Description");
>
> for-each ($ospf/ospf-neighbor) {
> var $ifname = interface-name;
> var $desc = {
> var $xdesc = $interfaces/*[name == $ifname]/description;
> if ($xdesc) {
> expr $xdesc;
> } else {
> var $ifd = substring-before($ifname, ".");
> expr $interfaces/*[name == $ifd]/description;
> }
> }
>
> <output> jcs:printf($fmt, neighbor-address, $ifname,
> ospf-neighbor-state, $desc);
> }
> }
> }
> }
>
More information about the juniper-nsp
mailing list