Skip to content

Commit

Permalink
Optimize techsupport reducing number of vtysh calls in scale sceario (#…
Browse files Browse the repository at this point in the history
…102)

<!--
 Please make sure you've read and understood our contributing guidelines:
 https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

 failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` **

 If this is a bug fix, make sure your description includes "closes #xxxx",
 "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related
 issue when the PR is merged.

 If you are adding/modifying/removing any command or utility script, please also
 make sure to add/modify/remove any unit tests from the tests
 directory as appropriate.

 If you are modifying or removing an existing 'show', 'config' or 'sonic-clear'
 subcommand, or you are adding a new subcommand, please make sure you also
 update the Command Line Reference Guide (doc/Command-Reference.md) to reflect
 your changes.

 Please provide the following information:
-->

#### 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)
  • Loading branch information
mssonicbld authored Jan 8, 2025
1 parent 1f6e706 commit a488e10
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

###############################################################################
Expand Down

0 comments on commit a488e10

Please sign in to comment.