Last active
August 29, 2015 14:08
-
-
Save linuxkidd/ab96477d539343eadd0d to your computer and use it in GitHub Desktop.
Output OSD size statistics, total PGs per OSD and per-pool PGs per OSD (primary PG count and secondary PG count)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import simplejson as json | |
obj=json.load(sys.stdin) | |
# osd_data_object osd.id = [ 'TotalPGs': [primary, secondary], 'PoolName1': [primary, secondary] , 'PoolName2': [primary, secondary], ... ]; | |
osd_data={} | |
# pool_data_object Pool.id = [ pool object from json ]; | |
pool_data={} | |
fields=['TotalPGs']; | |
for pool in obj['osdmap']['pools']: | |
pool_data[str(pool['pool'])]=pool | |
fields.append(pool['pool_name']); | |
for osd in obj['osdmap']['osds']: | |
osd_data[osd['osd']]={}; | |
for field in fields: | |
osd_data[osd['osd']][field]={'PrimPG#': 0, 'SecPG#': 0} | |
for pg in obj['pgmap']['pg_stats']: | |
poolID,_=pg['pgid'].split('.',1) | |
primSec='PrimPG#' | |
for osdIndex in range(0,len(pg['acting'])): | |
if osdIndex > 0: | |
primSec='SecPG#' | |
osd_data[pg['acting'][osdIndex]]['TotalPGs'][primSec]+=1 | |
osd_data[pg['acting'][osdIndex]][pool_data[poolID]['pool_name']][primSec]+=1 | |
print "osd\t"+"(pri,sec)\t".join(str(x) for x in fields) | |
for osdid in osd_data: | |
outline=str(osdid)+'\t' | |
for field in fields: | |
outline+='\t('+str(osd_data[osdid][field]['PrimPG#'])+','+str(osd_data[osdid][field]['SecPG#'])+')'; | |
print outline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment