Skip to content

Commit 3aec519

Browse files
authored
Fixed show interface counters on supervisor for packet chassis (sonic-net#3703)
* Added support to display only nonzero queue counter. Signed-off-by: Abhishek Dosi <[email protected]> * Update port2alias * For Config reload/minigraph stop and re-enable routeCheck because with large route scale of 70K+ routes this can log monit error Transiently which can also fail in sonic-mgmt. Signed-off-by: Abhishek Dosi <[email protected]> * Updated UT Signed-off-by: Abhishek Dosi <[email protected]> * Update portstat.py * Update portstat * Fix Signed-off-by: Abhishek Dosi <[email protected]> * Fix Signed-off-by: Abhishek Dosi <[email protected]> --------- Signed-off-by: Abhishek Dosi <[email protected]>
1 parent 428d6da commit 3aec519

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

scripts/portstat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ try:
2727
import sonic_py_common
2828
from swsscommon.swsscommon import SonicV2Connector
2929
sonic_py_common.device_info.is_supervisor = mock.MagicMock(return_value=True)
30+
sonic_py_common.device_info.is_voq_chassis = mock.MagicMock(return_value=True)
3031
SonicV2Connector.delete_all_by_pattern = mock.MagicMock()
3132
if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic":
3233
import mock_tables.mock_multi_asic

utilities_common/portstat.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
class Portstat(object):
123123
def __init__(self, namespace, display_option):
124124
self.db = None
125+
self.namespace = namespace
126+
self.display_option = display_option
125127
self.multi_asic = multi_asic_util.MultiAsic(display_option, namespace)
126128
if device_info.is_supervisor():
127129
self.db = SonicV2Connector(use_unix_socket_path=False)
@@ -132,7 +134,8 @@ def get_cnstat_dict(self):
132134
self.cnstat_dict['time'] = datetime.datetime.now()
133135
self.ratestat_dict = OrderedDict()
134136
if device_info.is_supervisor():
135-
self.collect_stat_from_lc()
137+
if device_info.is_voq_chassis() or (self.namespace is None and self.display_option != 'all'):
138+
self.collect_stat_from_lc()
136139
else:
137140
self.collect_stat()
138141
return self.cnstat_dict, self.ratestat_dict
@@ -405,7 +408,9 @@ def cnstat_print(self, cnstat_dict, ratestat_dict, intf_list, use_json, print_al
405408
print(table_as_json(table, header))
406409
else:
407410
print(tabulate(table, header, tablefmt='simple', stralign='right'))
408-
if (multi_asic.is_multi_asic() or device_info.is_chassis()) and not use_json:
411+
if device_info.is_voq_chassis():
412+
return
413+
elif (multi_asic.is_multi_asic() or device_info.is_packet_chassis()) and not use_json:
409414
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
410415

411416
def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list):
@@ -668,5 +673,7 @@ def cnstat_diff_print(self, cnstat_new_dict, cnstat_old_dict,
668673
print(table_as_json(table, header))
669674
else:
670675
print(tabulate(table, header, tablefmt='simple', stralign='right'))
671-
if (multi_asic.is_multi_asic() or device_info.is_chassis()) and not use_json:
676+
if device_info.is_voq_chassis():
677+
return
678+
elif (multi_asic.is_multi_asic() or device_info.is_packet_chassis()) and not use_json:
672679
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")

0 commit comments

Comments
 (0)