Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enable counters] provide initial rates parameters #5048

Merged
merged 4 commits into from
Nov 18, 2020
Merged
Changes from 3 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
18 changes: 18 additions & 0 deletions dockers/docker-orchagent/enable_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
import swsssdk
import time

# ALPHA defines the size of the window over which we calculate the average value. ALPHA is 2/(N+1) where N is the interval(window size)
# In this case we configure the window to be 10s. This way if we have a huge 1s spike in traffic,
# the average rate value will show a curve descending from the spike to the usual rate over approximately 10s.
DEFAULT_SMOOTH_INTERVAL = '10'
liat-grozovik marked this conversation as resolved.
Show resolved Hide resolved
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
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 @@ -19,6 +35,7 @@ def enable_counters():
enable_counter_group(db, 'QUEUE_WATERMARK')
enable_counter_group(db, 'BUFFER_POOL_WATERMARK')
enable_counter_group(db, 'PORT_BUFFER_DROP')
enable_rates()

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

if __name__ == '__main__':
main()