Skip to content

Commit

Permalink
Fixed show interface counters on supervisor for packet chassis (#103)
Browse files Browse the repository at this point in the history
What I did:

On Packet chassis for supervisor do the following:

`show interfaces counter` gets sats from LC

`show infeface counters -n <> -d all` gets internal port stats

`show infeface counters -d all` gets internal port stats

MSFT ADO: 30791268
  • Loading branch information
mssonicbld authored Jan 9, 2025
1 parent 74374d9 commit b784bb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/portstat
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ try:
import sonic_py_common
from swsscommon.swsscommon import SonicV2Connector
sonic_py_common.device_info.is_supervisor = mock.MagicMock(return_value=True)
sonic_py_common.device_info.is_voq_chassis = mock.MagicMock(return_value=True)
SonicV2Connector.delete_all_by_pattern = mock.MagicMock()
if os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] == "multi_asic":
import mock_tables.mock_multi_asic
Expand Down
13 changes: 10 additions & 3 deletions utilities_common/portstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
class Portstat(object):
def __init__(self, namespace, display_option):
self.db = None
self.namespace = namespace
self.display_option = display_option
self.multi_asic = multi_asic_util.MultiAsic(display_option, namespace)
if device_info.is_supervisor():
self.db = SonicV2Connector(use_unix_socket_path=False)
Expand All @@ -131,7 +133,8 @@ def get_cnstat_dict(self):
self.cnstat_dict['time'] = datetime.datetime.now()
self.ratestat_dict = OrderedDict()
if device_info.is_supervisor():
self.collect_stat_from_lc()
if device_info.is_voq_chassis() or (self.namespace is None and self.display_option != 'all'):
self.collect_stat_from_lc()
else:
self.collect_stat()
return self.cnstat_dict, self.ratestat_dict
Expand Down Expand Up @@ -399,7 +402,9 @@ def cnstat_print(self, cnstat_dict, ratestat_dict, intf_list, use_json, print_al
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if (multi_asic.is_multi_asic() or device_info.is_chassis()) and not use_json:
if device_info.is_voq_chassis():
return
elif (multi_asic.is_multi_asic() or device_info.is_packet_chassis()) and not use_json:
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")

def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list):
Expand Down Expand Up @@ -662,5 +667,7 @@ def cnstat_diff_print(self, cnstat_new_dict, cnstat_old_dict,
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if (multi_asic.is_multi_asic() or device_info.is_chassis()) and not use_json:
if device_info.is_voq_chassis():
return
elif (multi_asic.is_multi_asic() or device_info.is_packet_chassis()) and not use_json:
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")

0 comments on commit b784bb7

Please sign in to comment.