Fix ceph.chart.py for Python3 (#5396)
Gaetan Ferez committed
Feb 15, 2019 at 13:47 UTC
18fe4170054c98756a9d15500c4ca7f08e0cfef7
1 file changed
+6
-6
collectors/python.d.plugin/ceph/ceph.chart.py
+6
-6
@@ -161,7 +161,7 @@ class Service(SimpleService):
161
:return: None
162
"""
163
# Pool lines
164
- for pool in sorted(self._get_df()['pools']):
164
+ for pool in sorted(self._get_df()['pools'], key=lambda x:sorted(x.keys())):
165
self.definitions['pool_usage']['lines'].append([pool['name'],
166
pool['name'],
167
'absolute'])
@@ -182,7 +182,7 @@ class Service(SimpleService):
182
'absolute'])
183
184
# OSD lines
185
- for osd in sorted(self._get_osd_df()['nodes']):
185
+ for osd in sorted(self._get_osd_df()['nodes'], key=lambda x:sorted(x.keys())):
186
self.definitions['osd_usage']['lines'].append([osd['name'],
187
osd['name'],
188
'absolute'])
@@ -309,7 +309,7 @@ class Service(SimpleService):
309
return json.loads(self.cluster.mon_command(json.dumps({
310
'prefix': 'df',
311
'format': 'json'
312
- }), '')[1])
312
+ }), '')[1].decode('utf-8'))
313
314
def _get_osd_df(self):
315
"""
@@ -319,7 +319,7 @@ class Service(SimpleService):
319
return json.loads(self.cluster.mon_command(json.dumps({
320
'prefix': 'osd df',
321
'format': 'json'
322
- }), '')[1].replace('-nan', '"-nan"'))
322
+ }), '')[1].decode('utf-8').replace('-nan', '"-nan"'))
323
324
def _get_osd_perf(self):
325
"""
@@ -329,7 +329,7 @@ class Service(SimpleService):
329
return json.loads(self.cluster.mon_command(json.dumps({
330
'prefix': 'osd perf',
331
'format': 'json'
332
- }), '')[1])
332
+ }), '')[1].decode('utf-8'))
333
334
def _get_osd_pool_stats(self):
335
"""
@@ -341,4 +341,4 @@ class Service(SimpleService):
341
return json.loads(self.cluster.mon_command(json.dumps({
342
'prefix': 'osd pool stats',
343
'format': 'json'
344
- }), '')[1])
344
+ }), '')[1].decode('utf-8'))