diff --git a/dockers/docker-orchagent/enable_counters.py b/dockers/docker-orchagent/enable_counters.py index 5178684c5e16..2067baefbfb7 100755 --- a/dockers/docker-orchagent/enable_counters.py +++ b/dockers/docker-orchagent/enable_counters.py @@ -1,13 +1,16 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 -import swsssdk import time +import swsssdk + + def enable_counter_group(db, name): info = {} info['FLEX_COUNTER_STATUS'] = 'enable' db.mod_entry("FLEX_COUNTER_TABLE", name, info) + def enable_counters(): db = swsssdk.ConfigDBConnector() db.connect() @@ -20,10 +23,12 @@ def enable_counters(): enable_counter_group(db, 'BUFFER_POOL_WATERMARK') enable_counter_group(db, 'PORT_BUFFER_DROP') + def get_uptime(): with open('/proc/uptime') as fp: return float(fp.read().split(' ')[0]) + def main(): # If the switch was just started (uptime less than 5 minutes), # wait for 3 minutes and enable counters @@ -35,5 +40,6 @@ def main(): time.sleep(60) enable_counters() + if __name__ == '__main__': main()