Skip to content

Commit 8677d5f

Browse files
marian-pritsaklguohan
authored andcommitted
[pfcwd]: Refine 'show stats' output (#170)
Group columns in OK/DROP pairs Add option to show empty lines now hidden by default Signed-off-by: marian-pritsak <[email protected]>
1 parent 0fdd9f9 commit 8677d5f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

pfcwd/main.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
from natsort import natsorted
77

88
STATS_DESCRIPTION = [
9-
('STORM DETECTED CNT', 'PFC_WD_QUEUE_STATS_DEADLOCK_DETECTED'),
10-
('STORM RESTORED CNT', 'PFC_WD_QUEUE_STATS_DEADLOCK_RESTORED'),
11-
('TX PACKETS', 'PFC_WD_QUEUE_STATS_TX_PACKETS'),
12-
('RX PACKETS', 'PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS'),
13-
('TX PACKETS DROP', 'PFC_WD_QUEUE_STATS_RX_PACKETS'),
14-
('RX PACKETS DROP', 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST'),
15-
('TX PACKETS LAST', 'PFC_WD_QUEUE_STATS_TX_PACKETS_LAST'),
16-
('RX PACKETS LAST', 'PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST'),
17-
('TX PACKETS LAST DROP', 'PFC_WD_QUEUE_STATS_RX_PACKETS_LAST'),
18-
('RX PACKETS LAST DROP', 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST')
9+
('STORM DETECTED/RESTORED', 'PFC_WD_QUEUE_STATS_DEADLOCK_DETECTED', 'PFC_WD_QUEUE_STATS_DEADLOCK_RESTORED'),
10+
('TX OK/DROP', 'PFC_WD_QUEUE_STATS_TX_PACKETS', 'PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS'),
11+
('RX OK/DROP', 'PFC_WD_QUEUE_STATS_RX_PACKETS', 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS'),
12+
('TX LAST OK/DROP', 'PFC_WD_QUEUE_STATS_TX_PACKETS_LAST', 'PFC_WD_QUEUE_STATS_TX_DROPPED_PACKETS_LAST'),
13+
('RX LAST OK/DROP', 'PFC_WD_QUEUE_STATS_RX_PACKETS_LAST', 'PFC_WD_QUEUE_STATS_RX_DROPPED_PACKETS_LAST'),
1914
]
2015

2116
CONFIG_DESCRIPTION = [
@@ -47,8 +42,9 @@ def show():
4742

4843
# Show stats
4944
@show.command()
45+
@click.option('-e', '--empty', is_flag = True)
5046
@click.argument('queues', nargs = -1)
51-
def stats(queues):
47+
def stats(empty, queues):
5248
""" Show PFC Watchdog stats per queue """
5349
db = swsssdk.SonicV2Connector(host='127.0.0.1')
5450
db.connect(db.COUNTERS_DB)
@@ -64,9 +60,10 @@ def stats(queues):
6460
if stats is None:
6561
continue
6662
for stat in STATS_DESCRIPTION:
67-
line = stats.get(stat[1], '0')
63+
line = stats.get(stat[1], '0') + '/' + stats.get(stat[2], '0')
6864
stats_list.append(line)
69-
table.append([queue] + stats_list)
65+
if stats_list != ['0/0'] * len(STATS_DESCRIPTION) or empty:
66+
table.append([queue] + stats_list)
7067

7168
click.echo(tabulate(table, STATS_HEADER, stralign='right', numalign='right', tablefmt='simple'))
7269

0 commit comments

Comments
 (0)