From 2e2efdacf3f43c9a0195dfc8b83d8b02667c5887 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:44:02 -0800 Subject: [PATCH 1/4] no print if use json format --- scripts/portstat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/portstat b/scripts/portstat index 0e3b9c438c..b32b1aaf2a 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -337,8 +337,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + if multi_asic.is_multi_asic(): + 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): """ @@ -555,8 +555,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + if multi_asic.is_multi_asic(): + print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def main(): parser = argparse.ArgumentParser(description='Display the ports state and counters', From cb79d57e081ca49e3631161e590752839e609d0e Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 10 Feb 2023 13:25:05 -0800 Subject: [PATCH 2/4] remove check for multi_asic single-asic linecards also have internal links connect to each other and sup --- scripts/portstat | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/portstat b/scripts/portstat index b32b1aaf2a..bb13f27eec 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -337,8 +337,7 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + 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): """ @@ -555,8 +554,7 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def main(): parser = argparse.ArgumentParser(description='Display the ports state and counters', From 4f4c6107ac9f304c7232621e5c123e44883e8057 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Fri, 10 Feb 2023 16:53:25 -0800 Subject: [PATCH 3/4] add back multi_asic check as this original change is mainly for multi-asic production devices --- scripts/portstat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/portstat b/scripts/portstat index bb13f27eec..f8eb0e20c2 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -337,7 +337,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + if multi_asic.is_multi_asic(): + 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): """ @@ -554,7 +555,8 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") + if multi_asic.is_multi_asic(): + print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def main(): parser = argparse.ArgumentParser(description='Display the ports state and counters', From cc6f5a6a1dad528e2885278bc309d516a53c6b96 Mon Sep 17 00:00:00 2001 From: wenyiz2021 <91497961+wenyiz2021@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:41:18 -0800 Subject: [PATCH 4/4] add print for chassis --- scripts/portstat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/portstat b/scripts/portstat index f8eb0e20c2..27696729e9 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -17,6 +17,7 @@ from collections import OrderedDict, namedtuple from natsort import natsorted from tabulate import tabulate from sonic_py_common import multi_asic +from sonic_py_common import device_info # mock the redis for unit test purposes # try: @@ -337,7 +338,7 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): + if multi_asic.is_multi_asic() or device_info.is_chassis(): 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): @@ -555,7 +556,7 @@ class Portstat(object): print(table_as_json(table, header)) else: print(tabulate(table, header, tablefmt='simple', stralign='right')) - if multi_asic.is_multi_asic(): + if multi_asic.is_multi_asic() or device_info.is_chassis(): print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n") def main():