[j-nsp] BGP Peer formatting

Ben Dale bdale at comlinx.com.au
Tue Sep 23 00:11:44 EDT 2014


On 23 Sep 2014, at 1:48 pm, Phil Shafer <phil at juniper.net> wrote:

> 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

Love your work Phil : )

That's a heck of a lot simpler/cleaner than the recursive monstrosity I've been putting together!

Changes have been pulled into github, so if you're running 11.4 or earlier, give it another try now.

Ben


More information about the juniper-nsp mailing list