Skip to content

[intfstat] Fix logic in RIF counters to print right stats#5

Closed
noaOrMlnx wants to merge 1 commit intomasterfrom
rif_logic_fix
Closed

[intfstat] Fix logic in RIF counters to print right stats#5
noaOrMlnx wants to merge 1 commit intomasterfrom
rif_logic_fix

Conversation

@noaOrMlnx
Copy link
Copy Markdown
Owner

What I did

Fix logic in scripts/intfstat file.
Before the change:
If a user cleared all counters using sonic-clear rifcounters command and then queried for rif counters with a certain interface (e.g. show interfaces counters rif Ethernet0), the user would see the older stats. meaning the clear was not performed.
The reason for this is that when we do sonic-clear rifcounters, the counters are not really being cleared, but current stats are saved into a file, and in the next counters query, it will calculate the diff between current counters and the saved counters.
If the clear was performed in general (without an interface name), it's saved to a general file (e.g. 0).
If the clear was performed for a certain interface, it's saved to an interface file (e.g. 0-Ethernet0).
so when we clear in one method and then query for the other, we can receive the info from the wrong file and display different stats.

How I did it

Add the logic:
when deleting for a certain interface, add the info to the general file.
when querying for a certain interface, check the general file as well.

How to verify it

  • send traffic to interface

  • check general rif table (show interfaces counters rif)

  • clear general rifcounters (sonic-clear rifcounters)

  • check that the specific interface table is also updated (show interfaces counters rif Ethernet0)

  • send traffic to interface

  • clear interface table (sonic-clear rifcounters Ethernet0)

  • check that general table is updated as well (show interfaces counters rif)

Previous command output (if the output of a command-line utility has changed)

N/A

New command output (if the output of a command-line utility has changed)

N/A

Copy link
Copy Markdown

@BasimShalata BasimShalata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@noaOrMlnx noaOrMlnx force-pushed the rif_logic_fix branch 2 times, most recently from 57400af to 7247566 Compare August 4, 2021 14:00
@noaOrMlnx noaOrMlnx closed this Aug 24, 2021
noaOrMlnx pushed a commit that referenced this pull request Jul 17, 2024
…aidump_by_route_size (sonic-net#2972)

* * [saidump]
•	Saidump for DNX-SAI sonic-net/sonic-buildimage#13561

Solution and modification:
To use the redis-db SAVE option to save the snapshot of DB each time and recover later, instead of looping through each entry in the table and saving it.

(1) Updated sonic-buildimage/build_debian.sh, to install Python library rdbtools into the host.
(2) Updated sonic-buildimage/src/sonic-sairedis/saidump/saidump.cpp, add a new option -r, which updates the rdbtools's output-JSON files' format.
(3) Add a new script file: files/scripts/saidump.sh, to do the below steps
  For each ASIC0, such as ASIC0,

  #1. Save the Redis data.
  sudo sonic-db-cli -n asic$1 SAVE > /dev/null

  #2. Move dump files to /var/run/redisX/
  docker exec database$1 sh -c "mv /var/lib/redis/dump.rdb /var/run/redis$1/"

  #3. Run rdb command to convert the dump files into JSON files
  sudo python /usr/local/bin/rdb --command json  /var/run/redis$1/dump.rdb | sudo tee /var/run/redis$1/dump.json > /dev/null

  #4. Run saidump -r to update the JSON files' format as same as the saidump before. Then we can get the saidump result in standard output.
  docker exec syncd$1 sh -c "saidump -r /var/run/redis$1/dump.json"

  #5. clear
  sudo rm -f /var/run/redis$1/dump.rdb
  sudo rm -f /var/run/redis$1/dump.json

(4) Update sonic-buildimage/src/sonic-utilities/scripts/generate_dump, replace saidump with saidump.sh
* * [saidump]
•	Saidump for DNX-SAI sonic-net/sonic-buildimage#13561
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants