Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions show/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import re
import utilities_common.cli as clicommon
from natsort import natsorted
from collections import OrderedDict
from operator import itemgetter
from sonic_py_common import multi_asic
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector
from swsscommon import swsscommon
Expand Down Expand Up @@ -1003,11 +1005,12 @@ def metrics(db, port, json_output):
metrics_dict[asic_index] = per_npu_statedb[asic_index].get_all(
per_npu_statedb[asic_index].STATE_DB, 'MUX_METRICS_TABLE|{}'.format(port))

ordered_dict = OrderedDict(sorted(metrics_dict[asic_index].items(), key=itemgetter(1)))
if json_output:
click.echo("{}".format(json.dumps(metrics_dict[asic_index], indent=4)))
click.echo("{}".format(json.dumps(ordered_dict, indent=4)))
else:
print_data = []
for key, val in metrics_dict[asic_index].items():
for key, val in ordered_dict.items():
print_port_data = []
print_port_data.append(port)
print_port_data.append(key)
Expand Down
8 changes: 4 additions & 4 deletions tests/muxcable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@
PORT EVENT TIME
--------- ---------------------------- ---------------------------
Ethernet0 linkmgrd_switch_active_start 2021-May-13 10:00:21.420898
Ethernet0 linkmgrd_switch_standby_end 2021-May-13 10:01:15.696728
Ethernet0 xcvrd_switch_standby_end 2021-May-13 10:01:15.696051
Ethernet0 xcvrd_switch_standby_start 2021-May-13 10:01:15.690835
Ethernet0 xcvrd_switch_standby_end 2021-May-13 10:01:15.696051
Ethernet0 linkmgrd_switch_standby_end 2021-May-13 10:01:15.696728
"""

show_muxcable_metrics_expected_output_json = """\
{
"linkmgrd_switch_active_start": "2021-May-13 10:00:21.420898",
"linkmgrd_switch_standby_end": "2021-May-13 10:01:15.696728",
"xcvrd_switch_standby_start": "2021-May-13 10:01:15.690835",
"xcvrd_switch_standby_end": "2021-May-13 10:01:15.696051",
"xcvrd_switch_standby_start": "2021-May-13 10:01:15.690835"
"linkmgrd_switch_standby_end": "2021-May-13 10:01:15.696728"
}
"""

Expand Down