@@ -524,27 +524,42 @@ save_bgp_neighbor() {
524
524
local ns=$( get_vtysh_namespace $asic_id )
525
525
526
526
neighbor_list_v4=$( ${timeout_cmd} bash -c " vtysh $ns -c 'show ip bgp neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$ 4}' | awk /\\ \./" )
527
- for word in $neighbor_list_v4 ; do
528
- save_cmd " vtysh $ns -c \" show ip bgp neighbors $word advertised-routes\" " " ip.bgp.neighbor.$word .adv$asic_id "
529
- save_cmd " vtysh $ns -c \" show ip bgp neighbors $word routes\" " " ip.bgp.neighbor.$word .rcv$asic_id "
530
- done
527
+ if [ ! -z " $neighbor_list_v4 " ]; then
528
+ v4_cmd=" vtysh "
529
+ for word in $neighbor_list_v4 ; do
530
+ v4_cmd=" ${v4_cmd} $ns -Ec 'show bgp ipv4 neighbors $word advertised-routes' "
531
+ v4_cmd=" ${v4_cmd} $ns -Ec 'show bgp ipv4 neighbors $word routes' "
532
+ done
533
+ save_cmd " $v4_cmd " " ip.bgp.neigh.adv.rcv.routes"
534
+ fi
535
+
531
536
neighbor_list_v6=$( ${timeout_cmd} bash -c " vtysh $ns -c 'show bgp ipv6 neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$ 4}' | awk /:/" )
532
- for word in $neighbor_list_v6 ; do
533
- save_cmd " vtysh $ns -c \" show bgp ipv6 neighbors $word advertised-routes\" " " ipv6.bgp.neighbor.$word .adv$asic_id "
534
- save_cmd " vtysh $ns -c \" show bgp ipv6 neighbors $word routes\" " " ipv6.bgp.neighbor.$word .rcv$asic_id "
535
- done
537
+ if [ ! -z " $neighbor_list_v6 " ]; then
538
+ v6_cmd=" vtysh "
539
+ for word in $neighbor_list_v6 ; do
540
+ v6_cmd=" ${v6_cmd} $ns -Ec 'show bgp ipv6 neighbors $word advertised-routes' "
541
+ v6_cmd=" ${v6_cmd} $ns -Ec 'show bgp ipv6 neighbors $word routes' "
542
+ done
543
+ save_cmd " $v6_cmd " " ipv6.bgp.neigh.adv.rcv.routes"
544
+ fi
545
+
536
546
vrf_list=" "
537
547
vrf_output=$( ${timeout_cmd} bash -c " vtysh $ns -c 'show vrf'" )
538
548
if [ ! -z $vrf_output ]; then
539
549
vrf_list= echo $vrf_output | awk -F" " ' {print $2}'
540
550
fi
541
- for vrf in $vrf_list ; do
542
- neighbor_list=` ${timeout_cmd} bash -c " vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$ 4}'" `
543
- for word in $neighbor_list ; do
544
- save_cmd " vtysh $ns -c \" show ip bgp vrf $vrf neighbors $word advertised-routes\" " " ip.bgp.neighbor.$vrf .$word .adv$asic_id "
545
- save_cmd " vtysh $ns -c \" show ip bgp vrf $vrf neighbors $word routes\" " " ip.bgp.neighbor.$vrf .$word .rcv$asic_id "
551
+
552
+ if [ ! -z " $vrf_list " ]; then
553
+ vrf_cmd=" vtysh "
554
+ for vrf in $vrf_list ; do
555
+ neighbor_list=` ${timeout_cmd} bash -c " vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$ 4}'" `
556
+ for word in $neighbor_list ; do
557
+ vrf_cmd=" ${vrf_cmd} $ns -Ec 'show ip bgp vrf $vrf neighbors $word advertised-routes' "
558
+ vrf_cmd=" ${vrf_cmd} $ns -Ec 'show ip bgp vrf $vrf neighbors $word routes' "
559
+ done
546
560
done
547
- done
561
+ save_cmd " $vrf_cmd " " ip.bgp.neigh.vrf.adv.rcv.routes"
562
+ fi
548
563
}
549
564
550
565
# ##############################################################################
0 commit comments