Skip to content
Merged
Changes from 2 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
26 changes: 26 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,32 @@ def vrf(vrf_name):
body.append(["", intf])
click.echo(tabulate(body, header))

#
# 'events' command ("show event-counters")
#

@cli.command()
def event_counters():
"""Show events counter"""
# dump keys as formatted
counters_db = SonicV2Connector(host='127.0.0.1')
counters_db.connect(counters_db.COUNTERS_DB, retry_on=False)

header = ['name', 'count']
keys = counters_db.keys(counters_db.COUNTERS_DB, 'COUNTERS_EVENTS*')
table = []

for key in natsorted(keys):
key_list = key.split(':')
data_dict = counters_db.get_all(counters_db.COUNTERS_DB, key)
table.append((key_list[1], data_dict["value"]))

if table:
click.echo(tabulate(table, header, tablefmt='simple', stralign='right'))
else:
click.echo('No data available in COUNTERS_EVENTS\n')


#
# 'arp' command ("show arp")
#
Expand Down