Skip to content

Commit 05fa751

Browse files
authored
Fix the show interface counters throwing exception on device with no 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
1 parent f27dea0 commit 05fa751

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

scripts/portstat

+14-14
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,13 @@ class Portstat(object):
333333
format_number_with_comma(data['tx_err']),
334334
format_number_with_comma(data['tx_drop']),
335335
format_number_with_comma(data['tx_ovr'])))
336-
337-
if use_json:
338-
print(table_as_json(table, header))
339-
else:
340-
print(tabulate(table, header, tablefmt='simple', stralign='right'))
341-
if multi_asic.is_multi_asic() or device_info.is_chassis():
342-
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
336+
if table:
337+
if use_json:
338+
print(table_as_json(table, header))
339+
else:
340+
print(tabulate(table, header, tablefmt='simple', stralign='right'))
341+
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
342+
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
343343

344344
def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list):
345345
"""
@@ -551,13 +551,13 @@ class Portstat(object):
551551
format_number_with_comma(cntr['tx_err']),
552552
format_number_with_comma(cntr['tx_drop']),
553553
format_number_with_comma(cntr['tx_ovr'])))
554-
555-
if use_json:
556-
print(table_as_json(table, header))
557-
else:
558-
print(tabulate(table, header, tablefmt='simple', stralign='right'))
559-
if multi_asic.is_multi_asic() or device_info.is_chassis():
560-
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
554+
if table:
555+
if use_json:
556+
print(table_as_json(table, header))
557+
else:
558+
print(tabulate(table, header, tablefmt='simple', stralign='right'))
559+
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
560+
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
561561

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

0 commit comments

Comments
 (0)