[j-nsp] BGP Peer formatting

Phil Shafer phil at juniper.net
Mon Sep 22 23:48:25 EDT 2014


Ben Dale writes:
>Okay, one small caveat to this script - it looks like the use of mutable variables (mvar
> and set) was only introduced in SLAX 1.1 / Junos 12.2, so it's actually not going to wo
>rk on older versions of Junos.
>
>I know 11.4 is the trusted choice for most people on MX at the moment, so when I get som
>e time I'll attempt a mind-bending re-write using the older immutable var format.

In this case, you don't need the mvars.  Let sum() do the iteration:

        for-each ($neighbour-list/bgp-peer) {
            <output> jcs:printf("%-20s%-15s%-12s%-10s%-10s%-10s%-10s%-5s",
                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);   
        }

Thanks,
 Phil


More information about the juniper-nsp mailing list