summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2021-05-13 13:55:17 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2021-05-13 13:55:17 (GMT)
commitaf4a5292d86ab7f44dfb83e3e9a27da0d8aeda57 (patch)
treec2ff12ee181915f0030401be50f09e3b19e06f46
parent36122853fa73bad2f8fb5f3eb0464e0dea84a769 (diff)
downloadmisc-fred-af4a5292d86ab7f44dfb83e3e9a27da0d8aeda57.zip
misc-fred-af4a5292d86ab7f44dfb83e3e9a27da0d8aeda57.tar.gz
misc-fred-af4a5292d86ab7f44dfb83e3e9a27da0d8aeda57.tar.bz2
munin: update publik_recent_count to use python 3
-rwxr-xr-xmunin/publik_recent_count24
1 files changed, 12 insertions, 12 deletions
diff --git a/munin/publik_recent_count b/munin/publik_recent_count
index dc9974c..51bc78f 100755
--- a/munin/publik_recent_count
+++ b/munin/publik_recent_count
@@ -1,8 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
#%# family=auto
#%# capabilities=autoconf
-import cPickle
+import pickle
import datetime
import os
import psycopg2
@@ -16,18 +16,18 @@ for dirname in os.listdir('/var/lib/machines/'):
if len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
if base_dir:
- print 'yes'
+ print('yes')
else:
- print 'no'
+ print('no')
sys.exit(0)
if len(sys.argv) == 2 and sys.argv[1] == 'config':
- print '''graph_title Count of recently submitted forms
+ print('''graph_title Count of recently submitted forms
graph_category entrouvert
count_5m.label Count (5 minutes)
count_1h.label Count (1 hour)
count_1d.label Count (k) (1 day)
-'''
+''')
sys.exit(0)
total_5m = 0
@@ -45,12 +45,12 @@ for tenant in os.listdir(base_dir):
continue
if not os.path.isdir(os.path.join(base_dir, tenant)):
continue
- cfg = cPickle.load(open(os.path.join(base_dir, tenant, 'config.pck')))
- if not 'postgresql' in cfg:
+ cfg = pickle.load(open(os.path.join(base_dir, tenant, 'config.pck'), 'rb'), encoding='utf-8')
+ if 'postgresql' not in cfg:
continue
psql_cfg = {}
for k, v in cfg['postgresql'].items():
- if v and isinstance(v, basestring):
+ if v and isinstance(v, str):
psql_cfg[k] = v
pgconn = psycopg2.connect(**psql_cfg)
try:
@@ -62,6 +62,6 @@ for tenant in os.listdir(base_dir):
pass
pgconn.close()
-print 'count_5m.value', total_5m
-print 'count_1h.value', total_1h
-print 'count_1d.value', int(total_1d / 1000)
+print('count_5m.value %s' % total_5m)
+print('count_1h.value %s' % total_1h)
+print('count_1d.value %s' % (total_1d / 1000))