Skip to content

Commit

Permalink
fix error: interface counters is mismatch after warm-reboot (sonic-ne…
Browse files Browse the repository at this point in the history
…t#1099)

- What I did
There is a issue for counters after warm-reboot:
If I clear counters by command "sonic-clear counters", then execute 'warm-reboot' and whenSONiC is restart, the counters showed with command "show interface counters" is still old counters before "sonic-clear". It is not the right counters because the counters file in '/tmp' is lost in warm-reboot process.

- How I did it
I fixed it by saving '/tmp/portstat-0' folders in '/host/' before executing 'warm-reboot', and restore the counters folders back to '/tmp/' after warm-reboot process is finished (in pull request sonic-net/sonic-buildimage#5346 ).

- How to verify it
Clear counters by command 'sonic-clear'
sonic-clear counters
sonic-clear dropcounters
sonic-clear pfccounters
sonic-clear queuecounters
sonic-clear rifcounters
Execute 'warm-reboot'
Use command ‘show interface counters’ to see if the counters is right.
  • Loading branch information
JiangboHe authored Nov 20, 2020
1 parent be63918 commit eb38aeb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,25 @@ function unload_kernel()
fi
}
function save_counters_folder() {
debug "Saving counters folder before warmboot..."
counters_folder="/host/counters"
if [[ ! -d $counters_folder ]]; then
mkdir $counters_folder
fi
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
modules=("portstat-0" "dropstat" "pfcstat-0" "queuestat-0" "intfstat-0")
for module in ${modules[@]}
do
statfile="/tmp/$module"
if [[ -d $statfile ]]; then
cp -rf $statfile $counters_folder
fi
done
fi
}
# main starts here
parseOptions $@
Expand Down Expand Up @@ -401,6 +420,8 @@ case "$REBOOT_TYPE" in
;;
esac
save_counters_folder
unload_kernel
setup_reboot_variables
Expand Down

0 comments on commit eb38aeb

Please sign in to comment.