CounTeR

Enable/disable counter collection

CounTeR

Shortest form: ctr.

Show or change the SDK’s counter-collection task. The task periodically reads the hardware MIB counters into 64-bit software counters. Every port counter SONiC shows comes from those software counters. The shortest form is ctr.

  • With no argument, counter prints Current settings: and the current Interval, PortBitMap and DMA values. PortBitMap is a long hexadecimal bitmap followed by the port types it contains. On a SONiC switch the task runs every second (Interval=1000000) on cpu,ce,xe with DMA=True.

  • Key=value options come first: Interval=<usec>, PortBitMap=<pbmp> (Pbm) and DMA=<true|false>. Options you leave out keep their current values.

  • The words on, off and sync follow, in that order. They must be typed in full.

  • sync alone synchronises and returns. Every other form restarts the task with the resulting settings, or stops it if the interval is 0.

The built-in help says that omitting the interval prints it. The shell actually prints the settings only when there are no arguments at all.

Warning

counter off (or Interval=0) stops counter collection for the whole SDK. SONiC’s port, queue and buffer counters freeze, hardware counters can wrap unnoticed, and nothing in SONiC restarts the task. Any other form except sync restarts the task behind SONiC’s back.

Hardware-validated — Show the current interval, port bitmap and DMA setting

drivshell> counter
Current settings:
     Interval=1000000
     PortBitMap=0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000888888888888888c2222222222223e23, cpu,ce,xe
     DMA=True

Unvalidated — Collect every 2 s on all ports without DMA, as rc.soc does

drivshell> counter Interval=2000000 Pbm=all Dma=false

Broadcom’s rc.soc stops the task with counter off before re-initialising. It then starts it again with counter Interval=… Pbm=all Dma=… and runs counter sync (OpenBCM sdk-6.5.27/rc: rc.soc, config.bcm, td3_sanity.soc, cmd_td3_tr514_lr.soc, tr51/tr517_bcm56870_a0.soc, bcm_diag_info.soc …).

CounTeR off

Stop the counter task. The running interval is remembered for counter on. Stops SONiC’s counters; see the warning above.

Unvalidated

drivshell> counter off
CounTeR on

Restart the task with the interval remembered by the last counter off.

Warning

If counter off has not run since syncd started, there is no remembered interval, and counter on stops the task instead. To restart collection, give the interval explicitly (counter Interval=<usec>).

Unvalidated — Restore collection after counter off

drivshell> counter off
drivshell> counter on
CounTeR sync

Read all counters from hardware into the software counters, and reset the baseline that show counters uses for Changed (for the ports in PortBitMap). The task’s settings are not changed. Safe.

Unvalidated

drivshell> counter sync

Built-in help

Parameters:  [on] [off] [sync] [Interval=<usec>]
        [PortBitMap=<pbm>] [DMA=<true|false>]
    Starts the counter collection task and/or DMA running every <usec>
    microseconds.  The task tallies software counters based on hardware
    values and must run often enough to avoid counter overflow.
    If <interval> is 0, stops the task.  If <interval> is omitted, prints
    the current INTERVAL.  sync reads in all the counters to synchronize
    'show counters' for the first time, and must be used alone.

Further reading

SDK-6.5.20 HSDK Getting Started Guide (GS-SDK6520-R), plus SDK-6.5.20/21/22 Release Notes (RN-SDK65xx-R), OpenBCM sdk-6.5.27/rc: rc.soc, config.bcm, td3_sanity.soc, cmd_td3_tr514_lr.soc, tr51/tr517_bcm56870_a0.soc, bcm_diag_info.soc …, BCM_SDK命令, bcm cmd, Disabled Interface Counters (J-Net forum thread).