1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| def _collect_cluster_stats(self, path): """ If this service is a mon and it is the leader of a quorum, then publish statistics about the cluster. cluster_name, service_type, service_id = self._parse_socket_name(path) """ if service_type != 'mon': return
# We have a mon, see if it is the leader mon_status = self._admin_command(path, ['mon_status']) if mon_status['state'] != 'leader': return fsid = mon_status['monmap']['fsid'] # We are the leader, gather cluster-wide statistics
self.log.debug("mon leader found, gathering cluster stats for cluster '%s'" % cluster_name)
def publish_pool_stats(pool_id, stats): # Some of these guys we treat as counters, some as gauges delta_fields = ['num_read', 'num_read_kb', 'num_write', 'num_write_kb', 'num_objects_recovered','num_bytes_recovered', 'num_keys_recovered']
for k, v in stats.items(): self._publish_cluster_stats(cluster_name, fsid, "pool.{0}".format(pool_id), {k: v},counter=k in delta_fields)
# Gather "ceph pg dump pools" and file the stats by pool for pool in self._mon_command(cluster_name, ['pg', 'dump', 'pools']): publish_pool_stats(pool['poolid'], pool['stat_sum']) all_pools_stats = self._mon_command(cluster_name, ['pg', 'dump', 'summary'])['pg_stats_sum']['stat_sum']
publish_pool_stats('all', all_pools_stats) # Gather "ceph df" df = self._mon_command(cluster_name, ['df']) self._publish_cluster_stats(cluster_name, fsid, "df", df['stats'])
|