-
Notifications
You must be signed in to change notification settings - Fork 8
/
diskqueue_stats.py
executable file
·171 lines (166 loc) · 6.67 KB
/
diskqueue_stats.py
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import stats_buffer
import util_cli as util
class AvgDiskQueue:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
#print bucket, stats_info
disk_queue_avg_error = []
disk_queue_avg_warn = []
values = stats_info[accessor["scale"]][accessor["counter"]]
nodeStats = values["nodeStats"]
samplesCount = values["samplesCount"]
for node, vals in nodeStats.iteritems():
avg = sum(vals) / samplesCount
if avg > accessor["threshold"]["high"]:
disk_queue_avg_error.append({"node":node, "level":"red", "value":avg})
elif avg > accessor["threshold"]["low"]:
disk_queue_avg_warn.append({"node":node, "level":"yellow", "value":avg})
if len(disk_queue_avg_error) > 0:
result[bucket] = {"error" : disk_queue_avg_error}
if len(disk_queue_avg_warn) > 0:
result[bucket] = {"warn" : disk_queue_avg_warn}
return result
class DiskQueueTrend:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
trend_error = []
trend_warn = []
values = stats_info[accessor["scale"]][accessor["counter"]]
timestamps = values["timestamp"]
timestamps = [x - timestamps[0] for x in timestamps]
nodeStats = values["nodeStats"]
samplesCount = values["samplesCount"]
for node, vals in nodeStats.iteritems():
a, b = util.linreg(timestamps, vals)
if a > accessor["threshold"]["high"]:
trend_error.append({"node":node, "level":"red", "value":a})
elif a > accessor["threshold"]["low"]:
trend_warn.append({"node":node, "level":"yellow", "value":a})
if len(trend_error) > 0:
result[bucket] = {"error" : trend_error}
if len(trend_warn) > 0:
result[bucket] = {"warn" : trend_warn}
return result
class TapQueueTrend:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
trend_error = []
trend_warn = []
values = stats_info[accessor["scale"]][accessor["counter"]]
timestamps = values["timestamp"]
timestamps = [x - timestamps[0] for x in timestamps]
nodeStats = values["nodeStats"]
samplesCount = values["samplesCount"]
for node, vals in nodeStats.iteritems():
a, b = util.linreg(timestamps, vals)
if a > accessor["threshold"]["high"]:
trend_error.append({"node":node, "level":"red", "value":a})
elif a > accessor["threshold"]["low"]:
trend_warn.append({"node":node, "level":"yellow", "value":a})
if len(trend_error) > 0:
result[bucket] = {"error" : trend_error}
if len(trend_warn) > 0:
result[bucket] = {"warn" : trend_warn}
return result
class DiskQueueDrainingRate:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
#print bucket, stats_info
disk_queue_avg_error = []
disk_queue_avg_warn = []
drain_values = stats_info[accessor["scale"]][accessor["counter"][0]]
len_values = stats_info[accessor["scale"]][accessor["counter"][1]]
nodeStats = drain_values["nodeStats"]
samplesCount = drain_values["samplesCount"]
for node, vals in nodeStats.iteritems():
avg = sum(vals) / samplesCount
disk_len_vals = len_values["nodeStats"][node]
len_avg = sum(disk_len_vals) / samplesCount
if avg < accessor["threshold"]["drainRate"] and len_avg > accessor["threshold"]["diskLength"]:
disk_queue_avg_error.append({"node":node, "level":"red", "value":avg})
if len(disk_queue_avg_error) > 0:
result[bucket] = {"error" : disk_queue_avg_error}
return result
DiskQueueCapsule = [
{"name" : "DiskQueueDiagnosis",
"description" : "",
"ingredients" : [
{
"name" : "avgDiskQueueLength",
"description" : "Persistence severely behind - averge disk queue length is above threshold",
"counter" : "disk_write_queue",
"pernode" : True,
"scale" : "minute",
"code" : "AvgDiskQueue",
"threshold" : {
"low" : 50000000,
"high" : 1000000000
},
},
{
"name" : "diskQueueTrend",
"description" : "Persistence severely behind - disk write queue continues growing",
"counter" : "disk_write_queue",
"pernode" : True,
"scale" : "hour",
"code" : "DiskQueueTrend",
"threshold" : {
"low" : 0,
"high" : 0.25
},
},
],
"indicator" : True,
},
{"name" : "ReplicationTrend",
"ingredients" : [
{
"name" : "replicationTrend",
"description" : "Replication severely behind - ",
"counter" : "ep_tap_total_total_backlog_size",
"pernode" : True,
"scale" : "hour",
"code" : "TapQueueTrend",
"threshold" : {
"low" : 0,
"high" : 0.2
},
}
],
"indicator" : True,
},
{"name" : "DiskQueueDrainingAnalysis",
"description" : "",
"ingredients" : [
{
"name" : "activeDiskQueueDrainRate",
"description" : "Persistence severely behind - active disk queue draining rate is below threshold",
"counter" : ["vb_active_queue_drain", "disk_write_queue"],
"pernode" : True,
"scale" : "minute",
"code" : "DiskQueueDrainingRate",
"threshold" : {
"drainRate" : 0,
"diskLength" : 100000,
},
},
{
"name" : "replicaDiskQueueDrainRate",
"description" : "Persistence severely behind - replica disk queue draining rate is below threshold",
"counter" : ["vb_replica_queue_drain", "disk_write_queue"],
"pernode" : True,
"scale" : "minute",
"code" : "DiskQueueDrainingRate",
"threshold" : {
"drainRate" : 0,
"diskLength" : 100000,
},
},
],
"indicator" : True,
},
]