From: mhdo2 Date: Thu, 19 Oct 2017 15:27:31 +0000 (-0400) Subject: mgr/influx: Added pg_summary function X-Git-Tag: v13.1.0~131^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb6caa1f5ca184c091eb11861401230f3ca70ef3;p=ceph.git mgr/influx: Added pg_summary function Signed-off-by: mhdo2 --- diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index a5d50a2d8d56..9e505263c4ab 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -76,6 +76,7 @@ class Module(MgrModule): def get_df_stats(self): df = self.get("df") data = [] + pool_info = {} df_types = [ 'bytes_used', @@ -91,7 +92,7 @@ class Module(MgrModule): 'quota_objects', 'quota_bytes' ] - + for df_type in df_types: for pool in df['pools']: point = { @@ -108,7 +109,48 @@ class Module(MgrModule): } } data.append(point) - return data + pool_info.update({str(pool['id']):pool['name']}) + return data, pool_info + + def get_pg_summary(self, pool_info): + time = datetime.utcnow().isoformat() + 'Z' + pg_sum = self.get('pg_summary') + osd_sum = pg_sum['by_osd'] + pool_sum = pg_sum['by_pool'] + data = [] + for osd_id, stats in osd_sum.iteritems(): + metadata = self.get_metadata('osd', "%s" % osd_id) + for stat in stats: + point_1 = { + "measurement": "ceph_pg_summary_osd", + "tags": { + "ceph_daemon": "osd." + str(osd_id), + "type_instance": stat, + "host": metadata['hostname'] + }, + "time" : time, + "fields" : { + "value": stats[stat] + } + } + data.append(point_1) + for pool_id, stats in pool_sum.iteritems(): + for stat in stats: + point_2 = { + "measurement": "ceph_pg_summary_pool", + "tags": { + "pool_name" : pool_info[pool_id], + "pool_id" : pool_id, + "type_instance" : stat, + }, + "time" : time, + "fields": { + "value" : stats[stat], + } + } + data.append(point_2) + return data + def get_daemon_stats(self): data = [] @@ -183,6 +225,7 @@ class Module(MgrModule): if not self.config['hostname']: self.log.error("No Influx server configured, please set one using: " "ceph influx config-set hostname ") + self.set_health_checks({ 'MGR_INFLUX_NO_SERVER': { 'severity': 'warning', @@ -207,8 +250,10 @@ class Module(MgrModule): # instead we'll catch the not found exception and inform the user if # db can not be created try: - client.write_points(self.get_df_stats(), 'ms') + df_stats, pools = self.get_df_stats() + client.write_points(df_stats, 'ms') client.write_points(self.get_daemon_stats(), 'ms') + client.write_points(self.get_pg_summary(pools)) self.set_health_checks(dict()) except ConnectionError as e: self.log.exception("Failed to connect to Influx host %s:%d", @@ -264,7 +309,7 @@ class Module(MgrModule): if cmd['prefix'] == 'influx self-test': daemon_stats = self.get_daemon_stats() assert len(daemon_stats) - df_stats = self.get_df_stats() + df_stats, pools = self.get_df_stats() result = { 'daemon_stats': daemon_stats,