Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed show interface counters on supervisor for packet chassis #3703

Merged
merged 13 commits into from
Jan 4, 2025
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 @@ -122,6 +122,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 @@ -132,7 +134,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 @@ -405,7 +408,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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean for voq chassis, we don't have internal links, so run with '-d all' makes no differences?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yejianquan : yes for voq chassis we have fabric links [not ethernet links] and we have separate command to get counters for those.

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 @@ -668,5 +673,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")
Loading