Skip to content

Commit 5481d0e

Browse files
authored
Optimize techsupport reducing number of vtysh calls in scale sceario (sonic-net#3605)
What I did Optimize techsupport collecting neighbor information having single call instead of multiple calls which increases techsupport time How I did it By combining all vtysh calls into one inside neighbor loop How to verify it Running techsupport with 256 neighbors. This reduces by more than 1.5 minutes
1 parent 7e2e59c commit 5481d0e

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

scripts/generate_dump

+29-14
Original file line numberDiff line numberDiff line change
@@ -524,27 +524,42 @@ save_bgp_neighbor() {
524524
local ns=$(get_vtysh_namespace $asic_id)
525525

526526
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+
531536
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+
536546
vrf_list=""
537547
vrf_output=$(${timeout_cmd} bash -c "vtysh $ns -c 'show vrf'")
538548
if [ ! -z $vrf_output]; then
539549
vrf_list= echo $vrf_output | awk -F" " '{print $2}'
540550
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
546560
done
547-
done
561+
save_cmd "$vrf_cmd" "ip.bgp.neigh.vrf.adv.rcv.routes"
562+
fi
548563
}
549564

550565
###############################################################################

0 commit comments

Comments
 (0)