-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnode_stats.py
More file actions
executable file
·383 lines (364 loc) · 12.5 KB
/
node_stats.py
File metadata and controls
executable file
·383 lines (364 loc) · 12.5 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
import stats_buffer
import util_cli as util
class NodeList:
def run(self, accessor):
result = []
for node, node_info in stats_buffer.nodes.iteritems():
result.append({"ip": node, "port": node_info['port'], "version" :node_info['version'], "os": node_info['os'], "status" :node_info['status']})
return result
class NumNodes:
def run(self, accessor):
result = []
result.append(len(stats_buffer.nodes))
return result
class NumDownNodes:
def run(self, accessor):
result = []
result.append(len(filter(lambda (a, b): b["status"]=="down", stats_buffer.nodes.items())))
return result
class NumWarmupNodes:
def run(self, accessor):
result = []
result.append(len(filter(lambda (a, b): b["status"]=="warmup", stats_buffer.nodes.items())))
return result
class NumFailOverNodes:
def run(self, accessor):
result = []
result.append(len(filter(lambda (a, b): b["clusterMembership"]!="active", stats_buffer.nodes.items())))
return result
class BucketList:
def run(self, accessor):
result = []
for bucket in stats_buffer.bucket_info.keys():
result.append({"name": bucket})
return result
class NodeStorageStats:
def run(self, accessor):
result = []
for node, values in stats_buffer.nodes.iteritems():
if values["StorageInfo"].has_key("hdd"):
result.append({"ip": values["host"],
"port": values["port"],
"type" : "hdd",
"free": util.size_label(values["StorageInfo"]["hdd"]["free"]),
"quotaTotal" : util.size_label(values["StorageInfo"]["hdd"]["quotaTotal"]),
"used" : util.size_label(values["StorageInfo"]["hdd"]["used"]),
"usedByData" : util.size_label(values["StorageInfo"]["hdd"]["usedByData"]),
"total" : util.size_label(values["StorageInfo"]["hdd"]["total"])})
if values["StorageInfo"].has_key("ram"):
result.append({"ip": values["host"],
"port": values["port"],
"type" : "ram",
"quotaTotal" : util.size_label(values["StorageInfo"]["ram"]["quotaTotal"]),
"used" : util.size_label(values["StorageInfo"]["ram"]["used"]),
"usedByData" : util.size_label(values["StorageInfo"]["ram"]["usedByData"]),
"total" : util.size_label(values["StorageInfo"]["ram"]["total"])})
return result
class NodeSystemStats:
def run(self, accessor):
result = []
for node, values in stats_buffer.nodes.iteritems():
result.append({"ip": values["host"],
"port": values["port"],
"cpuUtilization" :util.pretty_float(values["systemStats"]["cpu_utilization_rate"]),
"swapTotal": util.size_label(values["systemStats"]["swap_total"]),
"swapUsed" : util.size_label(values["systemStats"]["swap_used"]),
"currentItems" : values["systemStats"]["currentItems"],
"currentItemsTotal" : values["systemStats"]["currentItemsTotal"],
"replicaCurrentItems" : values["systemStats"]["replicaCurrentItems"]})
return result
class ConnectionTrend:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
values = stats_info[accessor["scale"]][accessor["counter"]]
timestamps = values["timestamp"]
timestamps = [x - timestamps[0] for x in timestamps]
nodeStats = values["nodeStats"]
samplesCount = values["samplesCount"]
trend = []
for node, vals in nodeStats.iteritems():
a, b = util.linreg(timestamps, vals)
trend.append((node, a, vals[-1]))
result[bucket] = trend
return result
class CalcTrend:
def run(self, accessor):
result = {}
for bucket, stats_info in stats_buffer.buckets.iteritems():
values = stats_info[accessor["scale"]][accessor["counter"]]
timestamps = values["timestamp"]
timestamps = [x - timestamps[0] for x in timestamps]
nodeStats = values["nodeStats"]
samplesCount = values["samplesCount"]
trend = []
for node, vals in nodeStats.iteritems():
a, b = util.linreg(timestamps, vals)
trend.append((node, a))
result[bucket] = trend
return result
class NodePerformanceStats:
def run(self, accessor):
result = {}
for bucket, bucket_stats in stats_buffer.node_stats.iteritems():
stats = []
for node, stats_info in bucket_stats.iteritems():
for key, value in stats_info.iteritems():
if key.find(accessor["counter"]) >= 0:
if accessor.has_key("threshold"):
if int(value) > accessor["threshold"]:
stats.append((node, (key, value)))
else:
if accessor.has_key("unit"):
if accessor["unit"] == "time":
stats.append((node, util.time_label(value)))
elif accessor["unit"] == "size":
stats.append((node, util.size_label(int(value))))
else:
stats.append((node, (key,value)))
result[bucket] = stats
return result
NodeCapsule = [
{"name" : "NodeStatus",
"ingredients" : [
{
"name" : "nodeList",
"description" : "Node list",
"code" : "NodeList",
},
{
"name" : "numNodes",
"description" : "Number of Nodes",
"code" : "NumNodes",
},
{
"name" : "numDownNodes",
"description" : "Number of Down Nodes",
"code" : "NumDownNodes",
},
{
"name" : "numWarmupNodes",
"description" : "Number of Warmup Nodes",
"code" : "NumWarmupNodes",
},
{
"name" : "numFailedOverNodes",
"description" : "Number of Nodes failed over",
"code" : "NumFailOverNodes",
},
],
"clusterwise" : False,
"nodewise" : True,
"perNode" : False,
"perBucket" : False,
},
{"name" : "NumberOfConnection",
"ingredients" : [
{
"name" : "connectionTrend",
"description" : "Connection Trend",
"counter" : "curr_connections",
"scale" : "minute",
"code" : "ConnectionTrend",
"threshold" : {
"high" : 10000,
},
},
],
"nodewise" : True,
"perNode" : True,
},
{"name" : "OOMError",
"ingredients" : [
{
"name" : "oomErrors",
"description" : "OOM Errors",
"counter" : "ep_oom_errors",
"scale" : "hour",
"code" : "CalcTrend",
},
{
"name" : "tempOomErrors",
"description" : "Temporary OOM Errors",
"counter" : "ep_tmp_oom_errors",
"scale" : "hour",
"code" : "CalcTrend",
},
]
},
{"name" : "bucketList",
"ingredients" : [
{
"name" : "bucketList",
"description" : "Bucket list",
"code" : "BucketList",
},
],
"nodewise" : True,
},
{"name" : "nodeStorageStats",
"ingredients" : [
{
"name" : "nodeStorageStats",
"description" : "Node storage stats",
"code" : "NodeStorageStats",
},
],
"nodewise" : True,
},
{"name" : "nodeSystemStats",
"ingredients" : [
{
"name" : "nodeSystemStats",
"description" : "Node system stats",
"code" : "NodeSystemStats",
},
],
"nodewise" : True,
},
{"name" : "tapPerformance",
"ingredients" : [
{
"name" : "backfillRemaining",
"description" : "Number of backfill remaining",
"counter" : "ep_tap_queue_backfillremaining",
"code" : "NodePerformanceStats",
},
{
"name" : "tapNack",
"description" : "Number of nacks",
"counter" : "num_tap_nack",
"code" : "NodePerformanceStats",
},
{
"name" : "tapIdle",
"description" : "Idle tap streams",
"counter" : "idle",
"code" : "NodePerformanceStats",
},
],
"perBucket" : True,
},
{"name" : "checkpointPerformance",
"ingredients" : [
{
"name" : "openCheckPoint",
"description" : "Items for open checkpoints",
"counter" : "num_checkpoint_items",
"code" : "NodePerformanceStats",
"threshold" : 10000,
},
],
"perBucket" : True,
},
{"name" : "diskPerformance",
"ingredients" : [
{
"name" : "diskCommit",
"description" : "Averge disk commit time",
"counter" : "disk_commit",
"code" : "NodePerformanceStats",
"unit" : "time",
},
{
"name" : "diskUpdate",
"description" : "Averge disk update time",
"counter" : "disk_update",
"code" : "NodePerformanceStats",
"unit" : "time",
},
{
"name" : "diskInsert",
"description" : "Averge disk insert time",
"counter" : "disk_insert",
"code" : "NodePerformanceStats",
"unit" : "time",
},
{
"name" : "diskDelete",
"description" : "Averge disk delete time",
"counter" : "disk_del",
"code" : "NodePerformanceStats",
"unit" : "time",
},
],
"perBucket" : True,
},
{"name" : "AverageDocumentSize",
"ingredients" : [
{
"name" : "averageDocumentSize",
"description" : "Average Document Size",
"counter" : "item_alloc_sizes",
"code" : "NodePerformanceStats",
"unit" : "size",
},
],
"perBucket" : True,
},
{"name" : "MemoryUsage",
"ingredients" : [
{
"name" : "totalMemoryUsage",
"description" : "Total memory usage",
"counter" : "total_heap_bytes",
"code" : "NodePerformanceStats",
"unit" : "size",
},
{
"name" : "totalFragmentation",
"description" : "Total memory fragmentation",
"counter" : "total_fragmentation_bytes",
"code" : "NodePerformanceStats",
"unit" : "size",
},
{
"name" : "totalInternalMemory",
"description" : "Total internal memory usage",
"counter" : "mem_used",
"code" : "NodePerformanceStats",
"unit" : "size",
},
{
"name" : "overhead",
"description" : "Memory overhead",
"counter" : "ep_overhead",
"scale" : "hour",
"code" : "NodePerformanceStats",
"unit" : "size",
},
],
"perBucket" : True,
},
{"name" : "EPEnginePerformance",
"ingredients" : [
{
"name" : "flusherState",
"description" : "Engine flusher state",
"counter" : "ep_flusher_state",
"code" : "NodePerformanceStats",
},
{
"name" : "flusherCompleted",
"description" : "Flusher completed",
"counter" : "ep_flusher_num_completed",
"code" : "NodePerformanceStats",
},
{
"name" : "avgItemLoadTime",
"description" : "Average item loaded time",
"counter" : "ep_bg_load_avg",
"code" : "NodePerformanceStats",
"unit" : "time"
},
{
"name" : "avgItemWaitTime",
"description" : "Averge item waited time",
"counter" : "ep_bg_wait_avg",
"code" : "NodePerformanceStats",
"unit" : "time",
},
],
"perNode" : True,
},
]