Reduce rados API calls and add Improve read/write data and operations on pools
Luis Eduardo committed
Jan 26, 2018 at 11:54 UTC
bcbcf88dc87c9ed1dbc5a3c2e3508ed9907d9a3d
2 files changed
+57
-32
python.d/ceph.chart.py
+45
-28
@@ -17,8 +17,9 @@ priority = 60000
17
retries = 60
18
19
ORDER = ['general_usage', 'general_objects', 'general_bytes', 'general_operations',
20
- 'general_latency', 'pool_usage', 'pool_objects', 'pool_read_iops',
21
- 'pool_write_iops', 'osd_usage', 'osd_apply_latency', 'osd_commit_latency']
20
+ 'general_latency', 'pool_usage', 'pool_objects', 'pool_read_bytes',
21
+ 'pool_write_bytes', 'pool_read_operations', 'pool_write_operations', 'osd_usage',
22
+ 'osd_apply_latency', 'osd_commit_latency']
23
24
CHARTS = {
25
'general_usage': {
@@ -66,12 +67,20 @@ CHARTS = {
67
'options': [None, 'Ceph Pools', 'objects', 'pool', 'ceph.pool_objects', 'line'],
68
'lines': []
69
},
69
- 'pool_write_iops': {
70
- 'options': [None, 'Ceph Write Pool IOPS', 'KB', 'pool', 'ceph.pool_wio', 'area'],
70
+ 'pool_read_bytes': {
71
+ 'options': [None, 'Ceph Read Pool Data/s', 'KB', 'pool', 'ceph.pool_read_bytes', 'area'],
72
'lines': []
73
},
73
- 'pool_read_iops': {
74
- 'options': [None, 'Ceph Read Pool IOPS', 'KB', 'pool', 'ceph.pool_rio', 'area'],
74
+ 'pool_write_bytes': {
75
+ 'options': [None, 'Ceph Write Pool Data/s', 'KB', 'pool', 'ceph.pool_write_bytes', 'area'],
76
+ 'lines': []
77
+ },
78
+ 'pool_read_operations': {
79
+ 'options': [None, 'Ceph Read Pool Operations/s', 'operations', 'pool', 'ceph.pool_read_operations', 'area'],
80
+ 'lines': []
81
+ },
82
+ 'pool_write_operations': {
83
+ 'options': [None, 'Ceph Write Pool Operations/s', 'operations', 'pool', 'ceph.pool_write_operations', 'area'],
84
'lines': []
85
},
86
'osd_usage': {
@@ -124,7 +133,7 @@ class Service(SimpleService):
133
Create dynamically charts options
134
:return: None
135
"""
127
- # Lines
136
+ # Pool lines
137
for pool in sorted(self._get_df()['pools']):
138
self.definitions['pool_usage']['lines'].append([pool['name'],
139
pool['name'],
@@ -132,13 +141,20 @@ class Service(SimpleService):
141
self.definitions['pool_objects']['lines'].append(["obj_{0}".format(pool['name']),
142
pool['name'],
143
'absolute'])
135
- self.definitions['pool_read_iops']['lines'].append(['read_{0}'.format(pool['name']),
144
+ self.definitions['pool_read_bytes']['lines'].append(['read_{0}'.format(pool['name']),
145
pool['name'],
137
- 'incremental'])
138
- self.definitions['pool_write_iops']['lines'].append(['write_{0}'.format(pool['name']),
146
+ 'absolute', 1, 1024])
147
+ self.definitions['pool_write_bytes']['lines'].append(['write_{0}'.format(pool['name']),
148
pool['name'],
140
- 'incremental'])
149
+ 'absolute', 1, 1024])
150
+ self.definitions['pool_read_operations']['lines'].append(['read_operations_{0}'.format(pool['name']),
151
+ pool['name'],
152
+ 'absolute'])
153
+ self.definitions['pool_write_operations']['lines'].append(['write_operations_{0}'.format(pool['name']),
154
+ pool['name'],
155
+ 'absolute'])
156
157
+ # OSD lines
158
for osd in sorted(self._get_osd_df()['nodes']):
159
self.definitions['osd_usage']['lines'].append([osd['name'],
160
osd['name'],
@@ -157,12 +173,17 @@ class Service(SimpleService):
173
"""
174
try:
175
data = {}
160
- data.update(self._get_general())
161
- for pool in self._get_df()['pools']:
176
+ df = self._get_df()
177
+ osd_df = self._get_osd_df()
178
+ osd_perf = self._get_osd_perf()
179
+ pool_stats = self._get_osd_pool_stats()
180
+ data.update(self._get_general(df, osd_perf, pool_stats))
181
+ for pool in df['pools']:
182
data.update(self._get_pool_usage(pool))
183
data.update(self._get_pool_objects(pool))
164
- data.update(self._get_pool_rw_io(pool))
165
- for osd in self._get_osd_df()['nodes']:
184
+ for pool_io in pool_stats:
185
+ data.update(self._get_pool_rw(pool_io))
186
+ for osd in osd_df['nodes']:
187
data.update(self._get_osd_usage(osd))
188
data.update(self._get_osd_latency())
189
return data
@@ -170,15 +191,11 @@ class Service(SimpleService):
191
self.error(error)
192
return None
193
173
- def _get_general(self):
194
+ def _get_general(self, df, osd_perf, pool_stats):
195
"""
196
Get ceph's general usage
197
:return: dict
198
"""
178
- df = self._get_df()
179
- pool_stats = self._get_osd_pool_stats()
180
- osd_perf = self._get_osd_perf()
181
-
199
general_objects = 0
200
read_bytes_sec = 0
201
write_bytes_sec = 0
@@ -223,16 +240,16 @@ class Service(SimpleService):
240
"""
241
return {'obj_{0}'.format(pool['name']): pool['stats']['objects']}
242
226
- def _get_pool_rw_io(self, pool):
243
+ def _get_pool_rw(self, pool):
244
"""
228
- Get read/write kb operations in a pool
229
- :return: dict
245
+ Get read/write kb and operations in a pool
246
+ :return: A pool dict with both read/write bytes and operations.
247
"""
231
- ioctx = self.cluster.open_ioctx(pool['name'])
232
- pool_status = ioctx.get_stats()
233
- ioctx.close()
234
- return {'read_{0}'.format(pool['name']): int(pool_status['num_rd_kb']),
235
- 'write_{0}'.format(pool['name']): int(pool_status['num_wr_kb'])}
248
+ return {'read_{0}'.format(pool['pool_name']): int(pool['client_io_rate'].get('read_bytes_sec', 0)),
249
+ 'write_{0}'.format(pool['pool_name']): int(pool['client_io_rate'].get('write_bytes_sec', 0)),
250
+ 'read_operations_{0}'.format(pool['pool_name']): int(pool['client_io_rate'].get('read_op_per_sec', 0)),
251
+ 'write_operations_{0}'.format(pool['pool_name']): int(pool['client_io_rate'].get('write_op_per_sec', 0))
252
+ }
253
254
def _get_osd_usage(self, osd):
255
"""
web/dashboard_info.js
+12
-4
@@ -1346,12 +1346,20 @@ netdataDashboard.context = {
1346
info: 'Shows info about number of objects presents on a pool.'
1347
},
1348
1349
- 'ceph.pool_wio': {
1350
- info: 'Shows info about write operations on a pool.'
1349
+ 'ceph.pool_read_bytes': {
1350
+ info: 'Shows info about read data per second on a pool.'
1351
},
1352
1353
- 'ceph.pool_rio': {
1354
- info: 'Shows info about read operations on a pool.'
1353
+ 'ceph.pool_write_bytes': {
1354
+ info: 'Shows info about write data per second on a pool.'
1355
+ },
1356
+
1357
+ 'ceph.pool_read_objects': {
1358
+ info: 'Shows info about read objects per second on a pool.'
1359
+ },
1360
+
1361
+ 'ceph.pool_write_objects': {
1362
+ info: 'Shows info about write objects per second on a pool.'
1363
},
1364
1365
'ceph.osd_usage': {