From a488e1003df11375e65c1f816c556fcbb69f0c22 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:51:52 +0800 Subject: [PATCH] Optimize techsupport reducing number of vtysh calls in scale sceario (#102) #### 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 Before the fix ![image](https://github.com/user-attachments/assets/54114d39-03c2-4314-bc63-28f00d9a8b96) After the fix ![image](https://github.com/user-attachments/assets/a0ba1b84-b46d-4c95-b622-44f3ef130b39) #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed) --- scripts/generate_dump | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/generate_dump b/scripts/generate_dump index 0f2d6b674..b0e529e9d 100755 --- a/scripts/generate_dump +++ b/scripts/generate_dump @@ -524,27 +524,42 @@ save_bgp_neighbor() { local ns=$(get_vtysh_namespace $asic_id) neighbor_list_v4=$(${timeout_cmd} bash -c "vtysh $ns -c 'show ip bgp neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}' | awk /\\\./") - for word in $neighbor_list_v4; do - save_cmd "vtysh $ns -c \"show ip bgp neighbors $word advertised-routes\"" "ip.bgp.neighbor.$word.adv$asic_id" - save_cmd "vtysh $ns -c \"show ip bgp neighbors $word routes\"" "ip.bgp.neighbor.$word.rcv$asic_id" - done + if [ ! -z "$neighbor_list_v4" ]; then + v4_cmd="vtysh " + for word in $neighbor_list_v4; do + v4_cmd="${v4_cmd} $ns -Ec 'show bgp ipv4 neighbors $word advertised-routes' " + v4_cmd="${v4_cmd} $ns -Ec 'show bgp ipv4 neighbors $word routes' " + done + save_cmd "$v4_cmd" "ip.bgp.neigh.adv.rcv.routes" + fi + neighbor_list_v6=$(${timeout_cmd} bash -c "vtysh $ns -c 'show bgp ipv6 neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}' | awk /:/") - for word in $neighbor_list_v6; do - save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word advertised-routes\"" "ipv6.bgp.neighbor.$word.adv$asic_id" - save_cmd "vtysh $ns -c \"show bgp ipv6 neighbors $word routes\"" "ipv6.bgp.neighbor.$word.rcv$asic_id" - done + if [ ! -z "$neighbor_list_v6" ]; then + v6_cmd="vtysh " + for word in $neighbor_list_v6; do + v6_cmd="${v6_cmd} $ns -Ec 'show bgp ipv6 neighbors $word advertised-routes' " + v6_cmd="${v6_cmd} $ns -Ec 'show bgp ipv6 neighbors $word routes' " + done + save_cmd "$v6_cmd" "ipv6.bgp.neigh.adv.rcv.routes" + fi + vrf_list="" vrf_output=$(${timeout_cmd} bash -c "vtysh $ns -c 'show vrf'") if [ ! -z $vrf_output]; then vrf_list= echo $vrf_output | awk -F" " '{print $2}' fi - for vrf in $vrf_list; do - neighbor_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}'"` - for word in $neighbor_list; do - save_cmd "vtysh $ns -c \"show ip bgp vrf $vrf neighbors $word advertised-routes\"" "ip.bgp.neighbor.$vrf.$word.adv$asic_id" - save_cmd "vtysh $ns -c \"show ip bgp vrf $vrf neighbors $word routes\"" "ip.bgp.neighbor.$vrf.$word.rcv$asic_id" + + if [ ! -z "$vrf_list" ]; then + vrf_cmd="vtysh " + for vrf in $vrf_list; do + neighbor_list=`${timeout_cmd} bash -c "vtysh $ns -c 'show ip bgp vrf $vrf neighbors' | grep 'BGP neighbor is' | awk -F '[, ]' '{print \$4}'"` + for word in $neighbor_list; do + vrf_cmd="${vrf_cmd} $ns -Ec 'show ip bgp vrf $vrf neighbors $word advertised-routes' " + vrf_cmd="${vrf_cmd} $ns -Ec 'show ip bgp vrf $vrf neighbors $word routes' " + done done - done + save_cmd "$vrf_cmd" "ip.bgp.neigh.vrf.adv.rcv.routes" + fi } ###############################################################################