Skip to content

Commit 7b188f6

Browse files
mykolafvolodymyrsamotiy
authored andcommitted
[enable counters] provide initial rates parameters (sonic-net#5048)
* [enable counters] provide initial rates parameters Signed-off-by: Mykola Faryma <[email protected]> * add descriptive comment Signed-off-by: Mykola Faryma <[email protected]> Co-authored-by: Volodymyr Samotiy <[email protected]>
1 parent 8c5c079 commit 7b188f6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

dockers/docker-orchagent/enable_counters.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
#!/usr/bin/env python3
22

33
import time
4-
54
import swsssdk
65

6+
# 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)
7+
# In this case we configure the window to be 10s. This way if we have a huge 1s spike in traffic,
8+
# the average rate value will show a curve descending from the spike to the usual rate over approximately 10s.
9+
DEFAULT_SMOOTH_INTERVAL = '10'
10+
DEFAULT_ALPHA = '0.18'
11+
712

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

1318

19+
def enable_rates():
20+
# set the default interval for rates
21+
counters_db = swsssdk.SonicV2Connector()
22+
counters_db.connect('COUNTERS_DB')
23+
counters_db.set('COUNTERS_DB', 'RATES:PORT', 'PORT_SMOOTH_INTERVAL', DEFAULT_SMOOTH_INTERVAL)
24+
counters_db.set('COUNTERS_DB', 'RATES:PORT', 'PORT_ALPHA', DEFAULT_ALPHA)
25+
counters_db.set('COUNTERS_DB', 'RATES:RIF', 'RIF_SMOOTH_INTERVAL', DEFAULT_SMOOTH_INTERVAL)
26+
counters_db.set('COUNTERS_DB', 'RATES:RIF', 'RIF_ALPHA', DEFAULT_ALPHA)
27+
28+
1429
def enable_counters():
1530
db = swsssdk.ConfigDBConnector()
1631
db.connect()
@@ -22,6 +37,7 @@ def enable_counters():
2237
enable_counter_group(db, 'QUEUE_WATERMARK')
2338
enable_counter_group(db, 'BUFFER_POOL_WATERMARK')
2439
enable_counter_group(db, 'PORT_BUFFER_DROP')
40+
enable_rates()
2541

2642

2743
def get_uptime():
@@ -43,3 +59,4 @@ def main():
4359

4460
if __name__ == '__main__':
4561
main()
62+

0 commit comments

Comments
 (0)