# ceph pg dump | awk '
/^pg_stat/ { col=1; while($col!="up") {col++}; col++ }
/^[0-9a-f]+\.[0-9a-f]+/ { match($0,/^[0-9a-f]+/); pool=substr($0, RSTART, RLENGTH); poollist[pool]=0;
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) }
for(i in osds) {array[osds[i],pool]++; osdlist[osds[i]];}
}
END {
printf("\n");
printf("pool :\t"); for (i in poollist) printf("%s\t",i); printf("| SUM \n");
for (i in poollist) printf("--------"); printf("----------------\n");
for (i in osdlist) { printf("osd.%i\t", i); sum=0;
for (j in poollist) { printf("%i\t", array[i,j]); sum+=array[i,j]; sumpool[j]+=array[i,j] }; printf("| %i\n",sum) }
for (i in poollist) printf("--------"); printf("----------------\n");
printf("SUM :\t"); for (i in poollist) printf("%s\t",sumpool[i]); printf("|\n");
}'
pool : 5 6 7 11 12 0 | SUM
----------------------------------------------------------------
osd.4 21 12 11 7 4 20 | 75
osd.17 0 1 19 0 0 0 | 20
osd.18 10 8 19 2 4 6 | 49
osd.5 24 17 3 2 2 11 | 59
osd.19 10 12 9 4 0 6 | 41
osd.6 13 12 9 6 6 19 | 65
osd.7 15 9 9 4 1 11 | 49
osd.8 13 15 15 3 3 13 | 62
osd.9 6 13 13 3 2 12 | 49
osd.10 12 10 13 2 2 3 | 42
osd.20 7 16 15 0 3 12 | 53
osd.11 23 10 9 4 2 9 | 57
osd.21 9 17 10 4 2 13 | 55
osd.12 8 17 6 2 1 11 | 45
osd.0 7 9 12 1 5 23 | 57
osd.13 14 7 13 3 5 10 | 52
osd.1 11 13 8 6 2 15 | 55
osd.14 10 15 8 1 1 13 | 48
osd.15 0 0 12 0 0 0 | 12
osd.2 21 14 14 3 8 17 | 77
osd.16 11 7 10 2 3 9 | 42
osd.3 11 22 19 3 4 12 | 71
----------------------------------------------------------------
SUM : 256 256 256 62 60 245 |