-
Notifications
You must be signed in to change notification settings - Fork 10
/
slow_by_osd-pool-type.awk
151 lines (143 loc) · 2.79 KB
/
slow_by_osd-pool-type.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/awk -f
#
# by: Michael Kidd
# https://github.com/linuxkidd
#
# Use:
# chmod 755 slow_by_osd-pool-type.awk
# ./slow_by_osd-pool-type.awk ceph.log
#
# Output Options:
# -v csv=1
# -v pivot=1
# -v perline=1
#
# Note: with no '-v' option specified, it provides 'visual' output for easy human parsing
# Note2: Only one output option may be used per execution
#
#
BEGIN {
PROCINFO["sorted_in"] = "@val_num_asc"
}
/slow request [3-5][0-9]\./ {
if($20 ~ /^[0-9]*\.[0-9a-fs]*$/) {
split($20,a,".")
b=$0
gsub(/^.*currently /,"",b)
gsub(/ from .*/, "", b)
slowtype[b]++
slowosd[$3]++
slowosdbytype[$3][b]++
slowbypool[a[1]]++
slowbypooltype[a[1]][b]++
slowpoolosdtype[a[1]][$3][b]++
slowtypepools[b][a[1]]++
}
}
function printVisual() {
print "Pool stats: "
for(p in slowbypool) {
print "Pool id: "p" Total slow: "slowbypool[p]
for (t in slowbypooltype[p]) {
print "\t"slowbypooltype[p][t]"\t"t
}
}
print ""
print ""
print "OSD Stats: "
for (o in slowosd) {
print "\t"o" "slowosd[o]
for (t in slowosdbytype[o]) {
print "\t\t"slowosdbytype[o][t]" "t
}
}
print ""
print ""
print "Slow by Type: "
for (t in slowtype) {
print "\t"slowtype[t]" "t
}
}
function printCSV() {
printf("Pool,")
for(t in slowtype) {
printf("%s,",t)
}
print ""
for(p in slowbypool) {
printf("%s,",p)
for (t in slowtype) {
printf("%d,",slowbypooltype[p][t])
}
print ""
}
printf("Total:,")
for (t in slowtype) {
printf("%d,",slowtype[t])
}
print ""
print ""
printf("OSD,")
for(t in slowtype) {
printf("%s,",t)
}
print ""
for (o in slowosd) {
printf("%s,",o)
for (t in slowtype) {
printf("%s,",slowosdbytype[o][t])
}
print ""
}
printf("Total:,")
for (t in slowtype) {
printf("%d,",slowtype[t])
}
print ""
}
function printPerLine() {
print "Pool,OSD,Type,Count"
for(p in slowpoolosdtype){
for(o in slowpoolosdtype[p]) {
for(t in slowpoolosdtype[p][o])
print p","o","t","slowpoolosdtype[p][o][t]
}
}
}
function printPivot() {
printf(",")
for(t in slowtype) {
printf("%s",t)
for(p in slowtypepools[t]) {
l2=l2","p
ptotal=ptotal","slowtypepools[t][p]
sumtotal+=slowtypepools[t][p]
printf(",")
}
}
print "Totals"
printf("OSD / Pool ID%s\n",l2)
for(o in slowosd) {
printf("%s,",o)
for(t in slowtype) {
for(p in slowtypepools[t]) {
if(slowpoolosdtype[p][o][t]>0)
printf("%d,",slowpoolosdtype[p][o][t])
else
printf(",")
}
}
print slowosd[o]
}
print "Totals:"ptotal","sumtotal
}
END {
if(csv==1)
printCSV()
else if(pivot==1)
printPivot()
else if(perline==1)
printPerLine()
else
printVisual()
}