Skip to content

[show][interface] Add changes for show interface errors command#3721

Merged
prgeor merged 13 commits intosonic-net:masterfrom
vdahiya12:dev/vdahiya/add-ch-er
Jan 23, 2025
Merged

[show][interface] Add changes for show interface errors command#3721
prgeor merged 13 commits intosonic-net:masterfrom
vdahiya12:dev/vdahiya/add-ch-er

Conversation

@vdahiya12
Copy link
Copy Markdown
Contributor

@vdahiya12 vdahiya12 commented Jan 17, 2025

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)


admin@sonic$ show int errors Ethernet76
Port Errors                     Count  Last timestamp(UTC)
----------------------------  -------  ---------------------
code group error                    0  Never
crc rate                            0  Never
data unit crc error                 0  Never
data unit misalignment error        0  Never
data unit size                      0  Never
fec alignment loss                  0  Never
fec sync loss                       0  Never
high ber error                      0  Never
high ser error                      0  Never
mac local fault                     0  Never
mac remote fault                 7908  2025-01-17 19:34:13
no rx reachability                  0  Never
oper error status                   0  Never
signal local error                  0  Never

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vdahiya12 vdahiya12 changed the title [show][interface] Add changes for interface errors command [show][interface] Add changes for show interface errors command Jan 17, 2025
Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vdahiya12 vdahiya12 requested a review from prgeor January 17, 2025 20:29
Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

body.append([error.replace('_', ' '), count, timestamp])

# Sort the body for consistent display
body.sort(key=lambda x: x[0])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vdahiya12 can you double check if there is enough space the columns as displayed in the CLI command document?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

checked with the sample test output, we should be good

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 {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vdahiya12 maybe we can capture this in a function get_all_port_errors()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vdahiya12 not sure why we need this. The db value is always a key /value pari

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@r12f
Copy link
Copy Markdown

r12f commented Feb 1, 2025

Thanks Vaibhav! since all changes in 202411 will be automatically included in 202412. I have the 202412 tag removed now.

@mssonicbld
Copy link
Copy Markdown
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants