Created
July 25, 2019 17:30
-
-
Save linuxkidd/fdb92b2a4b33192589f4b7f4b2fbc2ed to your computer and use it in GitHub Desktop.
Determine statistical likelihood of PG splitting
This file contains hidden or 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 math | |
| import json as json | |
| debug=False | |
| obj=json.load(sys.stdin) | |
| lowsplit=40*2 | |
| highsplit=((40*2)+19) | |
| pgcounter=0 | |
| splitcounter={} | |
| couldsplitcount=0 | |
| splitthreshold=1.1 # 10 % | |
| for pg in obj['pgmap']['pg_stats']: | |
| pgcounter+=1 | |
| totfiles=pg['stat_sum']['num_objects']+pg['stat_sum']['num_object_clones'] | |
| couldsplitlevel=0 | |
| possiblelevel=0 | |
| splitlevel=1 | |
| while totfiles>lowsplit*(splitlevel*16): | |
| possiblelevel=splitlevel | |
| splitlevel+=1 | |
| if possiblelevel in splitcounter: | |
| splitcounter[possiblelevel]+=1 | |
| else: | |
| splitcounter[possiblelevel]=1 | |
| if possiblelevel>0: | |
| if totfiles<((lowsplit*(possiblelevel*16))*1.1) or totfiles<((highsplit*(possiblelevel*16))*splitthreshold): | |
| couldsplitlevel=possiblelevel | |
| if couldsplitlevel>0: | |
| print pg['pgid']+" within 10% of split level "+str(couldsplitlevel) | |
| couldsplitcount+=1 | |
| elif(debug): | |
| print pg['pgid']+" Not within 10% of split level "+str(possiblelevel)+" :: "+str(totfiles)+" / "+str(lowsplit*(possiblelevel*16))+" -> "+str(highsplit*(possiblelevel*16)) | |
| print "PG Split statistics:" | |
| for level in splitcounter: | |
| print "Split level "+str(level)+": "+str(splitcounter[level])+" pgs" | |
| print "\n"+str(couldsplitcount)+" PGs in possible split range of 10%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment