Skip to content

Commit 461e436

Browse files
authored
fix error: interface counters is mismatch after warm-reboot (#5346)
- Why I did it 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' (in pull request sonic-net/sonic-utilities#1099 ), and restore the counters folders back to '/tmp/' after warm-reboot process is finished. - 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.
1 parent 7bf05f7 commit 461e436

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

files/image_config/warmboot-finalizer/finalize-warmboot.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ function stop_control_plane_assistant()
7676
fi
7777
}
7878

79+
function restore_counters_folder()
80+
{
81+
debug "Restoring counters folder after warmboot..."
82+
83+
modules=("portstat-0" "dropstat" "pfcstat-0" "queuestat-0" "intfstat-0")
84+
for module in ${modules[@]}
85+
do
86+
statfile="/host/counters/$module"
87+
if [[ -d $statfile ]]; then
88+
mv $statfile /tmp/
89+
fi
90+
done
91+
}
92+
7993

8094
wait_for_database_service
8195

@@ -86,6 +100,8 @@ if [[ x"${WARM_BOOT}" != x"true" ]]; then
86100
exit 0
87101
fi
88102

103+
restore_counters_folder
104+
89105
list=${COMP_LIST}
90106

91107
# Wait up to 5 minutes

0 commit comments

Comments
 (0)