[show][interface] Add changes for show interface errors command#3721
Merged
prgeor merged 13 commits intosonic-net:masterfrom Jan 23, 2025
Merged
[show][interface] Add changes for show interface errors command#3721prgeor merged 13 commits intosonic-net:masterfrom
prgeor merged 13 commits intosonic-net:masterfrom
Conversation
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
prgeor
reviewed
Jan 18, 2025
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
prgeor
reviewed
Jan 18, 2025
| body.append([error.replace('_', ' '), count, timestamp]) | ||
|
|
||
| # Sort the body for consistent display | ||
| body.sort(key=lambda x: x[0]) |
Contributor
There was a problem hiding this comment.
@vdahiya12 can you double check if there is enough space the columns as displayed in the CLI command document?
Contributor
Author
There was a problem hiding this comment.
checked with the sample test output, we should be good
prgeor
reviewed
Jan 18, 2025
Comment on lines
+426
to
+435
| db = SonicV2Connector(host=REDIS_HOSTIP) | ||
| db.connect(db.STATE_DB) | ||
|
|
||
| # Retrieve the errors data from the PORT_OPERR_TABLE | ||
| port_operr_table = db.get_all(db.STATE_DB, 'PORT_OPERR_TABLE|{}'.format(interfacename)) | ||
| db.close(db.STATE_DB) | ||
|
|
||
| # Ensure port_operr_table is a dictionary | ||
| port_operr_table = port_operr_table or {} | ||
|
|
Contributor
There was a problem hiding this comment.
@vdahiya12 maybe we can capture this in a function get_all_port_errors()
prgeor
reviewed
Jan 18, 2025
show/interfaces/__init__.py
Outdated
| port_operr_table = db.get_all(db.STATE_DB, 'PORT_OPERR_TABLE|{}'.format(interfacename)) | ||
| db.close(db.STATE_DB) | ||
|
|
||
| # Ensure port_operr_table is a dictionary |
Contributor
There was a problem hiding this comment.
@vdahiya12 not sure why we need this. The db value is always a key /value pari
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <[email protected]>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
prgeor
approved these changes
Jan 23, 2025
|
Thanks Vaibhav! since all changes in 202411 will be automatically included in 202412. I have the 202412 tag removed now. |
Collaborator
|
Cherry-pick PR to 202411: #3749 |
nmoray
pushed a commit
to nmoray/sonic-utilities
that referenced
this pull request
Jun 25, 2025
…c-net#3721) * [show][interface] Add changes for interface errors command Signed-off-by: Vaibhav Dahiya <[email protected]> * remove redundant lines Signed-off-by: Vaibhav Dahiya <[email protected]> * add correction Signed-off-by: Vaibhav Dahiya <[email protected]> * back reverted Signed-off-by: Vaibhav Dahiya <[email protected]> * add ch Signed-off-by: Vaibhav Dahiya <[email protected]> * fix static Signed-off-by: Vaibhav Dahiya <[email protected]> * add phg Signed-off-by: Vaibhav Dahiya <[email protected]> * add prest Signed-off-by: Vaibhav Dahiya <[email protected]> * add fgr Signed-off-by: Vaibhav Dahiya <[email protected]> * add all Signed-off-by: Vaibhav Dahiya <[email protected]> * remove all redundant spaces Signed-off-by: Vaibhav Dahiya <[email protected]> * add key Signed-off-by: Vaibhav Dahiya <[email protected]> * add cgre Signed-off-by: Vaibhav Dahiya <[email protected]> --------- Signed-off-by: Vaibhav Dahiya <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MSFT ADO 30169175
What I did
This pull request introduces a new subcommand to the show interfaces command, allowing users to view error statistics for network interfaces. The new errors subcommand displays a table of potential interface errors, including error types, counts, and the last timestamp (in UTC) when the error occurred. If an error has not been encountered, the count defaults to 0, and the timestamp is displayed as Never. This change helps users easily identify any issues with their network interfaces and track error occurrences.
How I did it
To implement the errors subcommand, added a new command handler to the show/interfaces/init.py file. The handler retrieves the error data for a specified interface from the PORT_OPERR_TABLE in the database. The error types are predefined in a list, and for each type, the count and timestamp are pulled from the table. The results are then formatted into a table using the tabulate library, sorted alphabetically by error type.
How to verify it
UT and running the changes on a testbed
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)