Skip to content

Commit

Permalink
[intfstat] add intfstat script to output RIF counters (sonic-net#439)
Browse files Browse the repository at this point in the history
* [intfstat] 'add show interface counters rif'

Signed-off-by: Mykola Faryma <[email protected]>

* [rif counters] add unittests

Signed-off-by: Mykola Faryma <[email protected]>

* [setup] add test dependencies packages(mock, mockredipy)

Signed-off-by: Mykola Faryma <[email protected]>

* [intfstat] add alias mode support

Signed-off-by: Mykola Faryma <[email protected]>
  • Loading branch information
mykolaf authored and liat-grozovik committed Feb 18, 2019
1 parent b44b462 commit 8b6aea1
Show file tree
Hide file tree
Showing 14 changed files with 844 additions and 84 deletions.
9 changes: 9 additions & 0 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ def counters():
command = "portstat -c"
run_command(command)

@cli.command()
@click.argument('interface', metavar='<interface_name>', required=False, type=str)
def rifcounters(interface):
"""Clear RIF counters"""
command = "intfstat -c"
if interface is not None:
command = "intfstat -i {} -c".format(interface)
run_command(command)

@cli.command()
def queuecounters():
"""Clear queue counters"""
Expand Down
37 changes: 37 additions & 0 deletions counterpoll/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,40 @@ def disable():
port_info['FLEX_COUNTER_STATUS'] = 'disable'
configdb.mod_entry("FLEX_COUNTER_TABLE", "PORT", port_info)

# RIF counter commands
@cli.group()
def rif():
""" RIF counter commands """

@rif.command()
@click.argument('poll_interval')
def interval(poll_interval):
""" Set rif counter query interval """
configdb = swsssdk.ConfigDBConnector()
configdb.connect()
rif_info = {}
if poll_interval is not None:
rif_info['POLL_INTERVAL'] = poll_interval
configdb.mod_entry("FLEX_COUNTER_TABLE", "RIF", rif_info)

@rif.command()
def enable():
""" Enable rif counter query """
configdb = swsssdk.ConfigDBConnector()
configdb.connect()
rif_info = {}
rif_info['FLEX_COUNTER_STATUS'] = 'enable'
configdb.mod_entry("FLEX_COUNTER_TABLE", "RIF", rif_info)

@rif.command()
def disable():
""" Disable rif counter query """
configdb = swsssdk.ConfigDBConnector()
configdb.connect()
rif_info = {}
rif_info['FLEX_COUNTER_STATUS'] = 'disable'
configdb.mod_entry("FLEX_COUNTER_TABLE", "RIF", rif_info)

# Watermark counter commands
@cli.group()
def watermark():
Expand Down Expand Up @@ -122,6 +156,7 @@ def show():
configdb.connect()
queue_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'QUEUE')
port_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'PORT')
rif_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'RIF')
queue_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'QUEUE_WATERMARK')
pg_wm_info = configdb.get_entry('FLEX_COUNTER_TABLE', 'PG_WATERMARK')

Expand All @@ -131,6 +166,8 @@ def show():
data.append(["QUEUE_STAT", queue_info["POLL_INTERVAL"] if 'POLL_INTERVAL' in queue_info else 'default (10000)', queue_info["FLEX_COUNTER_STATUS"] if 'FLEX_COUNTER_STATUS' in queue_info else 'disable' ])
if port_info:
data.append(["PORT_STAT", port_info["POLL_INTERVAL"] if 'POLL_INTERVAL' in port_info else 'default (1000)', port_info["FLEX_COUNTER_STATUS"] if 'FLEX_COUNTER_STATUS' in port_info else 'disable'])
if rif_info:
data.append(["RIF_STAT", rif_info["POLL_INTERVAL"] if 'POLL_INTERVAL' in rif_info else 'default (1000)', rif_info["FLEX_COUNTER_STATUS"] if 'FLEX_COUNTER_STATUS' in rif_info else 'disable'])
if queue_wm_info:
data.append(["QUEUE_WATERMARK_STAT", queue_wm_info["POLL_INTERVAL"] if 'POLL_INTERVAL' in queue_wm_info else 'default (1000)', queue_wm_info["FLEX_COUNTER_STATUS"] if 'FLEX_COUNTER_STATUS' in queue_wm_info else 'disable' ])
if pg_wm_info:
Expand Down
Loading

0 comments on commit 8b6aea1

Please sign in to comment.