Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def srv6counters():
command = ["srv6stat", "-c"]
run_command(command)


@cli.command()
def switchcounters():
"""Clear switch counters"""
command = ["switchstat", "-c"]
run_command(command)

#
# 'clear watermarks
#
Expand Down
66 changes: 63 additions & 3 deletions counterpoll/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import click
import json
from flow_counter_util.route import exit_if_route_flow_counter_not_support
from swsscommon.swsscommon import ConfigDBConnector
import utilities_common.cli as clicommon

from tabulate import tabulate
from sonic_py_common import device_info
from flow_counter_util.route import exit_if_route_flow_counter_not_support
from swsscommon.swsscommon import ConfigDBConnector
from swsscommon.swsscommon import CFG_FLEX_COUNTER_TABLE_NAME as CFG_FLEX_COUNTER_TABLE


BUFFER_POOL_WATERMARK = "BUFFER_POOL_WATERMARK"
PORT_BUFFER_DROP = "PORT_BUFFER_DROP"
Expand Down Expand Up @@ -540,6 +543,56 @@ def disable(ctx): # noqa: F811
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", "SRV6", srv6_info)


# Switch counter commands
@cli.group()
def switch():
""" Switch counter commands """
pass


@switch.command()
@clicommon.pass_db
@click.argument("poll_interval", type=click.IntRange(1000, 60000))
def interval(db, poll_interval): # noqa: F811
""" Set switch counter query interval """
table = CFG_FLEX_COUNTER_TABLE
key = "SWITCH"

data = {
"POLL_INTERVAL": poll_interval
}

db.cfgdb.mod_entry(table, key, data)


@switch.command()
@clicommon.pass_db
def enable(db): # noqa: F811
""" Enable switch counter query """
table = CFG_FLEX_COUNTER_TABLE
key = "SWITCH"

data = {
"FLEX_COUNTER_STATUS": ENABLE
}

db.cfgdb.mod_entry(table, key, data)


@switch.command()
@clicommon.pass_db
def disable(db): # noqa: F811
""" Disable switch counter query """
table = CFG_FLEX_COUNTER_TABLE
key = "SWITCH"

data = {
"FLEX_COUNTER_STATUS": DISABLE
}

db.cfgdb.mod_entry(table, key, data)


@cli.command()
def show():
""" Show the counter configuration """
Expand All @@ -561,6 +614,7 @@ def show():
wred_queue_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'WRED_ECN_QUEUE')
wred_port_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'WRED_ECN_PORT')
srv6_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'SRV6')
switch_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'SWITCH')

header = ("Type", "Interval (in ms)", "Status")
data = []
Expand Down Expand Up @@ -598,6 +652,12 @@ def show():
if srv6_info:
data.append(["SRV6_STAT", srv6_info.get("POLL_INTERVAL", DEFLT_10_SEC),
srv6_info.get("FLEX_COUNTER_STATUS", DISABLE)])
if switch_info:
data.append([
"SWITCH_STAT",
switch_info.get("POLL_INTERVAL", DEFLT_60_SEC),
switch_info.get("FLEX_COUNTER_STATUS", DISABLE)
])

if is_dpu(configdb) and eni_info:
data.append(["ENI_STAT", eni_info.get("POLL_INTERVAL", DEFLT_10_SEC),
Expand Down
138 changes: 111 additions & 27 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
* [Radius](#radius)
* [Radius show commands](#show-radius-commands)
* [Radius config commands](#Radius-config-commands)
* [Switch](#switch)
* [Switch Show commands](#switch-show-commands)
* [Switch Clear commands](#switch-clear-commands)
* [sFlow](#sflow)
* [sFlow Show commands](#sflow-show-commands)
* [sFlow Config commands](#sflow-config-commands)
Expand Down Expand Up @@ -5213,6 +5216,10 @@ The "detailed" subcommand is used to display more detailed interface counters. A
WRED Red Dropped Packets....................... 0
WRED Total Dropped Packets..................... 0

Trimmed Packets................................ 0
Trimmed Sent Packets........................... 0
Trimmed Dropped Packets........................ 0

Time Since Counters Last Cleared............... None
```

Expand Down Expand Up @@ -5273,11 +5280,11 @@ The "trim" subcommand is used to display the interface packet trimming related s
- Example:
```
admin@sonic:~$ show interfaces counters trim
IFACE STATE TRIM_PKTS
---------- ------- -----------
Ethernet0 U 0
Ethernet8 U 100
Ethernet16 U 200
IFACE STATE TRIM_PKTS TRIM_TX_PKTS TRIM_DRP_PKTS
---------- ------- ----------- -------------- ---------------
Ethernet0 U 0 0 0
Ethernet8 U 100 100 0
Ethernet16 U 200 100 100
```

**show interfaces description**
Expand Down Expand Up @@ -9893,28 +9900,28 @@ This command can be used to clear the counters for all queues of all ports. Note
...

admin@sonic:~$ show queue counters --trim
Port TxQ Trim/pkts
--------- ----- -----------
Ethernet0 UC0 0
Ethernet0 UC1 0
Ethernet0 UC2 0
Ethernet0 UC3 0
Ethernet0 UC4 0
Ethernet0 UC5 0
Ethernet0 UC6 0
Ethernet0 UC7 0
Ethernet0 UC8 0
Ethernet0 UC9 0
Ethernet0 MC0 N/A
Ethernet0 MC1 N/A
Ethernet0 MC2 N/A
Ethernet0 MC3 N/A
Ethernet0 MC4 N/A
Ethernet0 MC5 N/A
Ethernet0 MC6 N/A
Ethernet0 MC7 N/A
Ethernet0 MC8 N/A
Ethernet0 MC9 N/A
Port TxQ Trim/pkts TrimSent/pkts TrimDrop/pkts
--------- ----- ----------- --------------- ---------------
Ethernet0 UC0 0 0 0
Ethernet0 UC1 100 100 0
Ethernet0 UC2 200 100 100
Ethernet0 UC3 300 300 0
Ethernet0 UC4 400 200 200
Ethernet0 UC5 500 500 0
Ethernet0 UC6 600 300 300
Ethernet0 UC7 700 700 0
Ethernet0 UC8 800 400 400
Ethernet0 UC9 900 900 0
Ethernet0 MC0 N/A N/A N/A
Ethernet0 MC1 N/A N/A N/A
Ethernet0 MC2 N/A N/A N/A
Ethernet0 MC3 N/A N/A N/A
Ethernet0 MC4 N/A N/A N/A
Ethernet0 MC5 N/A N/A N/A
Ethernet0 MC6 N/A N/A N/A
Ethernet0 MC7 N/A N/A N/A
Ethernet0 MC8 N/A N/A N/A
Ethernet0 MC9 N/A N/A N/A
```

Optionally, you can specify an interface name in order to display only that particular interface
Expand Down Expand Up @@ -10328,6 +10335,83 @@ This command is to config the radius server for various parameter listed.
timeout Specify RADIUS server global timeout <1 - 60>

```

# Switch

This section explains the various show, configuration and clear commands available for users.

### Switch Show commands

This subsection explains how to display switch configuration or stats.

**show switch counters**

This command displays switch stats.

- Usage:
```bash
show switch counters [OPTIONS]
show switch counters all [OPTIONS]
show switch counters trim [OPTIONS]
show switch counters detailed [OPTIONS]
```

- Options:
- _-p,--period_: display stats over a specified period (in seconds)
- _-d,--display_: show internal interfaces
- _-n,--namespace_: namespace name or all
- _-j,--json_: display in JSON format
- _-v,--verbose_: enable verbose output

- Example:
```bash
admin@sonic:~$ show switch counters
TrimSent/pkts TrimDrop/pkts
--------------- ---------------
100 100

admin@sonic:~$ show switch counters all
TrimSent/pkts TrimDrop/pkts
--------------- ---------------
100 100

admin@sonic:~$ show switch counters trim
TrimSent/pkts TrimDrop/pkts
--------------- ---------------
100 100

admin@sonic:~$ show switch counters detailed
Trimmed Sent Packets........................... 100
Trimmed Dropped Packets........................ 100

admin@sonic:~$ show switch counters --json
{
"trim_drop": "100",
"trim_sent": "100"
}
```

### Switch Clear commands

This subsection explains how to clear switch stats.

**sonic-clear switchcounters**

This command is used to clear switch counters.

- Usage:
```bash
sonic-clear switchcounters
```

- Examples:
```bash
admin@sonic:~$ sonic-clear switchcounters
Cleared switch counters
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#switch)

## sFlow

### sFlow Show commands
Expand Down
Loading
Loading