Enable PG drop counters by default, set default values only on the first start (#10935)

Signed-off-by: Andriy Yurkiv <ayurkiv@nvidia.com>

Backport form master
Appropriate PR on master: #7735
Appropriate PR on master #6444

Why I did it
PG drop counters should be enabled by default (merge from master)
After "config reload" or "docker swss restart" all counters were enabled even if they were disabled before

How I did it
1)Add PG drop counter enable option to dockers/docker-orchagent/enable_counters.py
2) Check if entry already exist before set default values

How to verify it
- install image and run counterpoll show CLI command and then you will see PG_STAT_DROP enabled
- Disable few counters
    counterpoll pg-drop disable
    counterpoll port disable
- Save and reload
   config save
   config reload
- Check enable status
This commit is contained in:
Andriy Yurkiv 2022-06-22 19:43:02 +03:00 committed by GitHub
parent 02e0aff5e7
commit 38eef912e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,12 @@ import swsssdk
import time
def enable_counter_group(db, name):
info = {}
info['FLEX_COUNTER_STATUS'] = 'enable'
db.mod_entry("FLEX_COUNTER_TABLE", name, info)
entry_info = db.get_entry("FLEX_COUNTER_TABLE", name)
if not entry_info:
info = {}
info['FLEX_COUNTER_STATUS'] = 'enable'
db.mod_entry("FLEX_COUNTER_TABLE", name, info)
def enable_counters():
db = swsssdk.ConfigDBConnector()
@ -15,6 +18,7 @@ def enable_counters():
enable_counter_group(db, 'QUEUE')
enable_counter_group(db, 'PFCWD')
enable_counter_group(db, 'PG_WATERMARK')
enable_counter_group(db, 'PG_DROP')
enable_counter_group(db, 'QUEUE_WATERMARK')
enable_counter_group(db, 'BUFFER_POOL_WATERMARK')
enable_counter_group(db, 'PORT_BUFFER_DROP')