From f40002661a45dfeac8109243a9d480d36e5e9b20 Mon Sep 17 00:00:00 2001 From: Daniel Martin-Brito Date: Mon, 13 Feb 2017 14:17:57 +0000 Subject: [PATCH] jewel: change benchmark test and add iops fields add provisioned size per pool --- plugins/ceph_latency_plugin.py | 2 +- plugins/ceph_pool_plugin.py | 35 +++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) mode change 100755 => 100644 plugins/ceph_pool_plugin.py diff --git a/plugins/ceph_latency_plugin.py b/plugins/ceph_latency_plugin.py index 090dccd..e5142da 100644 --- a/plugins/ceph_latency_plugin.py +++ b/plugins/ceph_latency_plugin.py @@ -51,7 +51,7 @@ def get_stats(self): output = None try: output = subprocess.check_output( - "timeout 30s rados --cluster "+ self.cluster +" -p data bench 10 write -t 1 -b 65536 2>/dev/null | grep -i latency | awk '{print 1000*$3}'", shell=True) + "timeout 30s rados --cluster "+ self.cluster +" -p " + self.testpool + " bench 10 write -t 1 -b 65536 2>/dev/null | grep -i latency | awk '{print 1000*$3}'", shell=True) except Exception as exc: collectd.error("ceph-latency: failed to run rados bench :: %s :: %s" % (exc, traceback.format_exc())) diff --git a/plugins/ceph_pool_plugin.py b/plugins/ceph_pool_plugin.py old mode 100755 new mode 100644 index ab2378b..d9e84bb --- a/plugins/ceph_pool_plugin.py +++ b/plugins/ceph_pool_plugin.py @@ -53,8 +53,10 @@ def get_stats(self): try: osd_pool_cmdline='ceph osd pool stats -f json --cluster ' + self.cluster stats_output = subprocess.check_output(osd_pool_cmdline, shell=True) - cephdf_cmdline='ceph df -f json --cluster ' + self.cluster - df_output = subprocess.check_output(ceph_dfcmdline, shell=True) + ceph_df_cmdline='ceph df -f json --cluster ' + self.cluster + df_output = subprocess.check_output(ceph_df_cmdline, shell=True) + pool_ls_cmdline='ceph osd pool ls -f json --cluster ' + self.cluster + pool_ls_output = subprocess.check_output(pool_ls_cmdline, shell=True) except Exception as exc: collectd.error("ceph-pool: failed to ceph pool stats :: %s :: %s" % (exc, traceback.format_exc())) @@ -66,15 +68,37 @@ def get_stats(self): if df_output is None: collectd.error('ceph-pool: failed to ceph df :: output was None') + if pool_ls_output is None: + collectd.error('ceph-pool: failed to ceph osd pool ls :: output was None') + json_stats_data = json.loads(stats_output) json_df_data = json.loads(df_output) + json_rbd_data = {} + try: + json_pool_ls = json.loads(pool_ls_output) + for pool in json_pool_ls: + rbd_cmdline='rbd ls -l ' + pool + ' --format json --cluster ' + self.cluster + rbd_output = subprocess.check_output(rbd_cmdline, shell=True) + json_rbd_data[pool] = json.loads(rbd_output) + except Exception as exc: + collectd.error("ceph-pool: failed to rbd ls :: %s :: %s" + % (exc, traceback.format_exc())) + return + + # provisioned per pool (kB) + provision = {} + for pool_name, rbd_list in json_rbd_data.items(): + provision[pool_name] = 0 + for rbd in rbd_list: + provision[pool_name] = provision[pool_name] + rbd['size'] + # push osd pool stats results for pool in json_stats_data: pool_key = "pool-%s" % pool['pool_name'] data[ceph_cluster][pool_key] = {} pool_data = data[ceph_cluster][pool_key] - for stat in ('read_bytes_sec', 'write_bytes_sec', 'op_per_sec'): + for stat in ('read_bytes_sec', 'write_bytes_sec', 'read_op_per_sec', 'write_op_per_sec'): pool_data[stat] = pool['client_io_rate'][stat] if pool['client_io_rate'].has_key(stat) else 0 # push df results @@ -96,6 +120,11 @@ def get_stats(self): data[ceph_cluster]['cluster']['total_used'] = int(json_df_data['stats']['total_used']) * 1024.0 data[ceph_cluster]['cluster']['total_avail'] = int(json_df_data['stats']['total_avail']) * 1024.0 + # push provisioned per pools + for pool_name, pool_provision in provision.items(): + if pool_provision: + data[ceph_cluster]["pool-%s" % pool_name]['kb_provisioned'] = pool_provision + return data try: