From 29599247d8db859c47f0037fc2099a79885491c9 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 3 Nov 2020 01:07:44 +0000 Subject: [PATCH 1/2] [enable_counters.py] Convert to Python 3 --- dockers/docker-orchagent/enable_counters.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dockers/docker-orchagent/enable_counters.py b/dockers/docker-orchagent/enable_counters.py index 5178684c5e16..e469efb062ab 100755 --- a/dockers/docker-orchagent/enable_counters.py +++ b/dockers/docker-orchagent/enable_counters.py @@ -1,15 +1,18 @@ -#!/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 = swsssdk.ConfigDBConnector(decode_responses=True) db.connect() enable_counter_group(db, 'PORT') enable_counter_group(db, 'RIF') @@ -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() From e27f17bd760117cff53aec5297612ab07004a31a Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 6 Nov 2020 00:28:26 +0000 Subject: [PATCH 2/2] Remove 'decode_responses=True', as it is no longer necessary --- dockers/docker-orchagent/enable_counters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-orchagent/enable_counters.py b/dockers/docker-orchagent/enable_counters.py index e469efb062ab..2067baefbfb7 100755 --- a/dockers/docker-orchagent/enable_counters.py +++ b/dockers/docker-orchagent/enable_counters.py @@ -12,7 +12,7 @@ def enable_counter_group(db, name): def enable_counters(): - db = swsssdk.ConfigDBConnector(decode_responses=True) + db = swsssdk.ConfigDBConnector() db.connect() enable_counter_group(db, 'PORT') enable_counter_group(db, 'RIF')