Skip to content

Commit

Permalink
[enable counters] provide initial rates parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <[email protected]>
  • Loading branch information
Mykola Faryma committed Jul 27, 2020
1 parent c0d1616 commit cfb5cca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dockers/docker-orchagent/enable_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
import swsssdk
import time

DEFAULT_SMOOTH_INTERVAL = '10'
DEFAULT_ALPHA = '0.18'

def enable_counter_group(db, name):
info = {}
info['FLEX_COUNTER_STATUS'] = 'enable'
db.mod_entry("FLEX_COUNTER_TABLE", name, info)

def enable_rates():
# set the default interval for rates (N) as 10s, alpha is 2/(N+1)
counters_db = swsssdk.SonicV2Connector()
counters_db.connect('COUNTERS_DB')
counters_db.set('COUNTERS_DB', 'RATES:PORT', 'PORT_SMOOTH_INTERVAL', DEFAULT_SMOOTH_INTERVAL)
counters_db.set('COUNTERS_DB', 'RATES:PORT', 'PORT_ALPHA', DEFAULT_ALPHA)
counters_db.set('COUNTERS_DB', 'RATES:RIF', 'RIF_SMOOTH_INTERVAL', DEFAULT_SMOOTH_INTERVAL)
counters_db.set('COUNTERS_DB', 'RATES:RIF', 'RIF_ALPHA', DEFAULT_ALPHA)


def enable_counters():
db = swsssdk.ConfigDBConnector()
db.connect()
Expand All @@ -18,6 +31,7 @@ def enable_counters():
enable_counter_group(db, 'PG_WATERMARK')
enable_counter_group(db, 'QUEUE_WATERMARK')
enable_counter_group(db, 'BUFFER_POOL_WATERMARK')
enable_rates()

def get_uptime():
with open('/proc/uptime') as fp:
Expand All @@ -36,3 +50,4 @@ def main():

if __name__ == '__main__':
main()

0 comments on commit cfb5cca

Please sign in to comment.