Skip to content

Commit

Permalink
Fix the show interface counters throwing exception on device with no …
Browse files Browse the repository at this point in the history
…external interfaces

Cherry-pick of PR:sonic-net#2703

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi committed May 26, 2023
1 parent ff26d90 commit 09d7e54
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions scripts/portstat
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ class Portstat(object):
format_number_with_comma(data.tx_err),
format_number_with_comma(data.tx_drop),
format_number_with_comma(data.tx_ovr)))

if use_json:
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():
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
if table:
if use_json:
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:
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 @@ -522,13 +522,13 @@ class Portstat(object):
format_number_with_comma(cntr.tx_err),
format_number_with_comma(cntr.tx_drop),
format_number_with_comma(cntr.tx_ovr)))

if use_json:
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():
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
if table:
if use_json:
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:
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',
Expand Down

0 comments on commit 09d7e54

Please # to comment.