6
6
from natsort import natsorted
7
7
8
8
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' ),
19
14
]
20
15
21
16
CONFIG_DESCRIPTION = [
@@ -47,8 +42,9 @@ def show():
47
42
48
43
# Show stats
49
44
@show .command ()
45
+ @click .option ('-e' , '--empty' , is_flag = True )
50
46
@click .argument ('queues' , nargs = - 1 )
51
- def stats (queues ):
47
+ def stats (empty , queues ):
52
48
""" Show PFC Watchdog stats per queue """
53
49
db = swsssdk .SonicV2Connector (host = '127.0.0.1' )
54
50
db .connect (db .COUNTERS_DB )
@@ -64,9 +60,10 @@ def stats(queues):
64
60
if stats is None :
65
61
continue
66
62
for stat in STATS_DESCRIPTION :
67
- line = stats .get (stat [1 ], '0' )
63
+ line = stats .get (stat [1 ], '0' ) + '/' + stats . get ( stat [ 2 ], '0' )
68
64
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 )
70
67
71
68
click .echo (tabulate (table , STATS_HEADER , stralign = 'right' , numalign = 'right' , tablefmt = 'simple' ))
72
69
0 commit comments