Skip to content

Commit

Permalink
Merge pull request ceph#22436 from wido/mgr-telegraf-pg-stats
Browse files Browse the repository at this point in the history
mgr/telegraf: Send more PG status information to Telegraf

Reviewed-by: John Spray <[email protected]>
  • Loading branch information
tchaikov authored Jun 27, 2018
2 parents a2d2711 + 0d1335d commit 7d54bdd
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions src/pybind/mgr/telegraf/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,32 @@ def get_daemon_stats(self):

return data

def get_pg_stats(self):
stats = dict()

pg_status = self.get('pg_status')
for key in ['bytes_total', 'data_bytes', 'bytes_used', 'bytes_avail',
'num_pgs', 'num_objects', 'num_pools']:
stats[key] = pg_status[key]

pg_states = ['active', 'peering', 'clean', 'scrubbing', 'undersized',
'backfilling', 'recovering', 'degraded', 'inconsistent',
'remapped', 'backfill_toofull', 'wait_backfill',
'recovery_wait']

for state in pg_states:
stats['num_pgs_{0}'.format(state)] = 0

stats['num_pgs'] = pg_status['num_pgs']
for state in pg_status['pgs_by_state']:
states = state['state_name'].split('+')
for s in pg_states:
key = 'num_pgs_{0}'.format(s)
if s in states:
stats[key] += state['count']

return stats

def get_cluster_stats(self):
stats = dict()

Expand Down Expand Up @@ -174,29 +200,7 @@ def get_cluster_stats(self):
stats['num_mds_up'] = num_mds_up
stats['num_mds'] = num_mds_up + stats['num_mds_standby']

pg_status = self.get('pg_status')
for key in ['bytes_total', 'data_bytes', 'bytes_used', 'bytes_avail',
'num_pgs', 'num_objects', 'num_pools']:
stats[key] = pg_status[key]

stats['num_pgs_active'] = 0
stats['num_pgs_clean'] = 0
stats['num_pgs_scrubbing'] = 0
stats['num_pgs_peering'] = 0
for state in pg_status['pgs_by_state']:
states = state['state_name'].split('+')

if 'active' in states:
stats['num_pgs_active'] += state['count']

if 'clean' in states:
stats['num_pgs_clean'] += state['count']

if 'peering' in states:
stats['num_pgs_peering'] += state['count']

if 'scrubbing' in states:
stats['num_pgs_scrubbing'] += state['count']
stats.update(self.get_pg_stats())

data = list()
for key, value in stats.items():
Expand Down

0 comments on commit 7d54bdd

Please sign in to comment.