@@ -15,6 +15,7 @@ import sys
15
15
from collections import namedtuple , OrderedDict
16
16
from natsort import natsorted
17
17
from tabulate import tabulate
18
+ from sonic_py_common import multi_asic
18
19
19
20
# mock the redis for unit test purposes #
20
21
try :
24
25
sys .path .insert (0 , modules_path )
25
26
sys .path .insert (0 , tests_path )
26
27
import mock_tables .dbconnector # lgtm [py/unused-import]
28
+ if os .environ ["UTILITIES_UNIT_TESTING_TOPOLOGY" ] == "multi_asic" :
29
+ import mock_tables .mock_multi_asic
30
+ mock_tables .dbconnector .load_namespace_config ()
27
31
28
32
except KeyError :
29
33
pass
30
34
31
35
from swsscommon .swsscommon import SonicV2Connector
32
36
from utilities_common .cli import UserCache
37
+ from utilities_common import constants
38
+ import utilities_common .multi_asic as multi_asic_util
33
39
34
40
QueueStats = namedtuple ("QueueStats" , "queueindex, queuetype, totalpacket, totalbytes, droppacket, dropbytes" )
35
41
header = ['Port' , 'TxQ' , 'Counter/pkts' , 'Counter/bytes' , 'Drop/pkts' , 'Drop/bytes' ]
@@ -85,9 +91,15 @@ def build_json(port, cnstat):
85
91
86
92
87
93
class Queuestat (object ):
88
- def __init__ (self , voq = False ):
89
- self .db = SonicV2Connector (use_unix_socket_path = False )
90
- self .db .connect (self .db .COUNTERS_DB )
94
+ def __init__ (self , namespace , voq = False ):
95
+ self .db = None
96
+ self .multi_asic = multi_asic_util .MultiAsic (constants .DISPLAY_ALL , namespace )
97
+ if namespace is not None :
98
+ for ns in self .multi_asic .get_ns_list_based_on_options ():
99
+ self .db = multi_asic .connect_to_all_dbs_for_ns (ns )
100
+ else :
101
+ self .db = SonicV2Connector (use_unix_socket_path = False )
102
+ self .db .connect (self .db .COUNTERS_DB )
91
103
self .voq = voq
92
104
93
105
def get_queue_port (table_id ):
@@ -345,12 +357,14 @@ Examples:
345
357
parser .add_argument ('-v' , '--version' , action = 'version' , version = '%(prog)s 1.0' )
346
358
parser .add_argument ('-j' , '--json_opt' , action = 'store_true' , help = 'Print in JSON format' )
347
359
parser .add_argument ('-V' , '--voq' , action = 'store_true' , help = 'display voq stats' )
360
+ parser .add_argument ('-n' ,'--namespace' , default = None , help = 'Display queue counters for specific namespace' )
348
361
args = parser .parse_args ()
349
362
350
363
save_fresh_stats = args .clear
351
364
delete_stats = args .delete
352
365
voq = args .voq
353
366
json_opt = args .json_opt
367
+ namespace = args .namespace
354
368
355
369
port_to_show_stats = args .port
356
370
@@ -362,7 +376,7 @@ Examples:
362
376
if delete_stats :
363
377
cache .remove ()
364
378
365
- queuestat = Queuestat ( voq )
379
+ queuestat = Queuestat ( namespace , voq )
366
380
367
381
if save_fresh_stats :
368
382
queuestat .save_fresh_stats ()
0 commit comments