Skip to content

Add timestamps to gearbox FEC histogram#4577

Open
nkanchi-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:nkanchi.last-updated-timestamps
Open

Add timestamps to gearbox FEC histogram#4577
nkanchi-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:nkanchi.last-updated-timestamps

Conversation

@nkanchi-nexthop

Copy link
Copy Markdown

What I did

The gearbox FEC histogram counters (S0–S15) are polled periodically by FlexCounter, but users have no way to know when a given bin value last changed. Adding per-bin timestamps lets the operator determine the freshness of each gearbox FEC codeword error bucket.

How I did it

Changed the gearbox interface display to read from counter entries.

How to verify it

  • Configure FlexCounter to poll gearbox FEC histogram stats on a gearbox port.
  • Verify the gearbox counter entries for the port include the FEC histogram counters and corresponding _TIMESTAMP fields.
  • Run gearboxutil interfaces fec-histogram Ethernet0 and confirm both the Line and System tables show a Last Updated column.
  • Confirm timestamps are only updated when the corresponding counter value changes, not on every poll cycle.

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

root@humm119:/home/admin# gearboxutil interfaces fec-histogram Ethernet0

Ethernet0 Line
Symbol Errors Per Codeword         Codewords
----------------------------  --------------
BIN0                          13544912011756
BIN1                                       0
BIN2                                       0
BIN3                                       0
BIN4                                       0
BIN5                                       0
BIN6                                       0
BIN7                                       0
BIN8                                       0
BIN9                                       0
BIN10                                      0
BIN11                                      0
BIN12                                      0
BIN13                                      0
BIN14                                      0
BIN15                                      0

Ethernet0 System
Symbol Errors Per Codeword         Codewords
----------------------------  --------------
BIN0                          13549184048038
BIN1                                       0
BIN2                                       0
BIN3                                       0
BIN4                                       0
BIN5                                       0
BIN6                                       0
BIN7                                       0
BIN8                                       0
BIN9                                       0
BIN10                                      0
BIN11                                      0
BIN12                                      0
BIN13                                      0
BIN14                                      0
BIN15                                      0

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

root@humm119:/home/admin# gearboxutil interfaces fec-histogram Ethernet0

Ethernet0 Line
Symbol Errors Per Codeword         Codewords  Last Updated
----------------------------  --------------  -------------------
BIN0                          13544912011756  2026-05-27 21:33:49
BIN1                                       0  2026-05-21 16:05:52
BIN2                                       0  2026-05-21 16:05:52
BIN3                                       0  2026-05-21 16:05:52
BIN4                                       0  2026-05-21 16:05:52
BIN5                                       0  2026-05-21 16:05:52
BIN6                                       0  2026-05-21 16:05:52
BIN7                                       0  2026-05-21 16:05:52
BIN8                                       0  2026-05-21 16:05:52
BIN9                                       0  2026-05-21 16:05:52
BIN10                                      0  2026-05-21 16:05:52
BIN11                                      0  2026-05-21 16:05:52
BIN12                                      0  2026-05-21 16:05:52
BIN13                                      0  2026-05-21 16:05:52
BIN14                                      0  2026-05-21 16:05:52
BIN15                                      0  2026-05-21 16:05:52

Ethernet0 System
Symbol Errors Per Codeword         Codewords  Last Updated
----------------------------  --------------  -------------------
BIN0                          13549184048038  2026-05-27 21:33:49
BIN1                                       0  2026-05-21 16:05:52
BIN2                                       0  2026-05-21 16:05:52
BIN3                                       0  2026-05-21 16:05:52
BIN4                                       0  2026-05-21 16:05:52
BIN5                                       0  2026-05-21 16:05:52
BIN6                                       0  2026-05-21 16:05:52
BIN7                                       0  2026-05-21 16:05:52
BIN8                                       0  2026-05-21 16:05:52
BIN9                                       0  2026-05-21 16:05:52
BIN10                                      0  2026-05-21 16:05:52
BIN11                                      0  2026-05-21 16:05:52
BIN12                                      0  2026-05-21 16:05:52
BIN13                                      0  2026-05-21 16:05:52
BIN14                                      0  2026-05-21 16:05:52
BIN15                                      0  2026-05-21 16:05:52

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 29, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: nkanchi-nexthop / name: Nikhil Kanchi (68d1af5)

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nkanchi-nexthop nkanchi-nexthop force-pushed the nkanchi.last-updated-timestamps branch from 68d1af5 to fc4c6a2 Compare June 1, 2026 16:23
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nkanchi-nexthop nkanchi-nexthop marked this pull request as ready for review June 2, 2026 17:32
@nkanchi-nexthop nkanchi-nexthop marked this pull request as draft June 2, 2026 17:33
@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: Nikhil Kanchi <nkanchi@nexthop.ai>
Signed-off-by: Nikhil Kanchi <nkanchi@nexthop.ai>
@nkanchi-nexthop nkanchi-nexthop force-pushed the nkanchi.last-updated-timestamps branch from bf90ec8 to 5a2d601 Compare June 2, 2026 17:40
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@nkanchi-nexthop nkanchi-nexthop marked this pull request as ready for review June 5, 2026 17:01
@prgeor prgeor requested a review from Copilot June 11, 2026 23:31

Copilot AI left a comment

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.

Pull request overview

This PR enhances gearboxutil interfaces fec-histogram output by adding a per-bin “Last Updated” timestamp (derived from FlexCounter-provided *_TIMESTAMP fields) so operators can assess freshness of each FEC histogram bin.

Changes:

  • Add timestamp parsing/formatting for each FEC histogram bin (S0–S15) and display it as a new Last Updated column.
  • Introduce a shared timestamp format constant for the FEC histogram display.

Comment thread scripts/gearboxutil
Comment on lines +368 to +376
timestamp_ms = counters.get(f'{bin_name}_TIMESTAMP', None)
if timestamp_ms:
try:
ts_sec = int(timestamp_ms) / 1000.0
timestamp_str = datetime.fromtimestamp(ts_sec).strftime(FEC_HISTOGRAM_TS_FORMAT)
except (TypeError, ValueError):
timestamp_str = 'N/A'
else:
timestamp_str = 'N/A'
Comment thread scripts/gearboxutil
Comment on lines 380 to +381
if histogram_data:
print(tabulate(histogram_data, headers=['Symbol Errors Per Codeword', 'Codewords'], tablefmt='simple'))
print(tabulate(histogram_data, headers=['Symbol Errors Per Codeword', 'Codewords', 'Last Updated'], tablefmt='simple'))
Comment thread scripts/gearboxutil
Comment on lines 3 to 6
import sys
from datetime import datetime
from tabulate import tabulate
from natsort import natsorted
@prgeor

prgeor commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@nkanchi-nexthop please address the copilot comments

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.

5 participants