Skip to content

Commit

Permalink
mgr/zabbix: Send more PG information to Zabbix
Browse files Browse the repository at this point in the history
Send information about the status in which many Placement Groups
are so that triggers can be made to check if all PGs are active
for example.

Signed-off-by: Wido den Hollander <wido@42on.com>
  • Loading branch information
wido committed Jun 6, 2018
1 parent 7b3a730 commit 9c54334
Show file tree
Hide file tree
Showing 2 changed files with 584 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/pybind/mgr/zabbix/module.py
Expand Up @@ -135,6 +135,30 @@ def set_config_option(self, option, value):
self.config[option] = value
return True

def get_pg_stats(self):
stats = dict()

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_pg_{0}'.format(state)] = 0

pg_status = self.get('pg_status')

stats['num_pg'] = pg_status['num_pgs']

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

return stats

def get_data(self):
data = dict()

Expand Down Expand Up @@ -226,12 +250,7 @@ def get_data(self):
except ValueError:
pass

pg_summary = self.get('pg_summary')
num_pg = 0
for state, num in pg_summary['all'].items():
num_pg += num

data['num_pg'] = num_pg
data.update(self.get_pg_stats())

return data

Expand Down

0 comments on commit 9c54334

Please sign in to comment.