Get the count of Ceph PG's per OSD

 1ceph pg dump | awk '
 2BEGIN { IGNORECASE = 1 }
 3/^PG_STAT/ { col=1; while($col!="UP") {col++}; col++ }
 4 /^[0-9a-f]+\\.[0-9a-f]+/ { match($0,/^[0-9a-f]+/); pool=substr($0, RSTART, RLENGTH); poollist[pool]=0;
 5 up=$col; i=0; RSTART=0; RLENGTH=0; delete osds; while(match(up,/[0-9]+/)>0) { osds[++i]=substr(up,RSTART,RLENGTH); up = substr(up, RSTART+RLENGTH) }
 6 for(i in osds) {array[osds[i],pool]++; osdlist[osds[i]];}
 7}
 8END {
 9printf("\
10");
11printf("pool :\\t"); for (i in poollist) printf("%s\\t",i); printf("| SUM \
12");
13for (i in poollist) printf("--------"); printf("----------------\
14");
15for (i in osdlist) { printf("osd.%i\\t", i); sum=0;
16for (j in poollist) { printf("%i\\t", array[i,j]); sum+=array[i,j]; sumpool[j]+=array[i,j] }; printf("| %i\
17",sum) }
18for (i in poollist) printf("--------"); printf("----------------\
19");
20printf("SUM :\\t"); for (i in poollist) printf("%s\\t",sumpool[i]); printf("|\
21");
22}'

Original article