Skip to content

Commit 77b725c

Browse files
authored
Fix the show interface counters throwing exception on device with no external interfaces (#2851)
Cherry-pick of PR:#2703 Signed-off-by: Abhishek Dosi <[email protected]>
1 parent ff26d90 commit 77b725c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

scripts/portstat

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ class Portstat(object):
320320
format_number_with_comma(data.tx_err),
321321
format_number_with_comma(data.tx_drop),
322322
format_number_with_comma(data.tx_ovr)))
323-
324-
if use_json:
325-
print(table_as_json(table, header))
326-
else:
327-
print(tabulate(table, header, tablefmt='simple', stralign='right'))
328-
if multi_asic.is_multi_asic() or device_info.is_chassis():
329-
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
323+
if table:
324+
if use_json:
325+
print(table_as_json(table, header))
326+
else:
327+
print(tabulate(table, header, tablefmt='simple', stralign='right'))
328+
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
329+
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
330330

331331
def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list):
332332
"""
@@ -522,13 +522,13 @@ class Portstat(object):
522522
format_number_with_comma(cntr.tx_err),
523523
format_number_with_comma(cntr.tx_drop),
524524
format_number_with_comma(cntr.tx_ovr)))
525-
526-
if use_json:
527-
print(table_as_json(table, header))
528-
else:
529-
print(tabulate(table, header, tablefmt='simple', stralign='right'))
530-
if multi_asic.is_multi_asic() or device_info.is_chassis():
531-
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
525+
if table:
526+
if use_json:
527+
print(table_as_json(table, header))
528+
else:
529+
print(tabulate(table, header, tablefmt='simple', stralign='right'))
530+
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
531+
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
532532

533533
def main():
534534
parser = argparse.ArgumentParser(description='Display the ports state and counters',

0 commit comments

Comments
 (0)