Skip to content

Commit

Permalink
Fix the show interface counters throwing exception on device with n…
Browse files Browse the repository at this point in the history
…o external interfaces (#2703)

Fix the `show interface counters` throwing exception
issue where device do not have any external ports and all are internal links (ethernet or fabric) which is possible in chassis
  • Loading branch information
abdosi committed Mar 17, 2023
1 parent f27dea0 commit 05fa751
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 @@ -333,13 +333,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 @@ -551,13 +551,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 05fa751

Please sign in to comment.