| 1 |
#!/usr/bin/env python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# [Riak](https://wiki.basho.com/display/RIAK/Riak) is a Dynamo-inspired |
| 5 |
# key/value store. |
| 6 |
# |
| 7 |
# This module collects metrics from the JSON stats interface of riak, available |
| 8 |
# at http://localhost:8098/stats. The statistics-aggregator must be enabled in |
| 9 |
# your riak configuration for this to work: |
| 10 |
# {riak_kv, [ |
| 11 |
# %% ... |
| 12 |
# {riak_kv_stat, true}, |
| 13 |
# %% ... |
| 14 |
# ]}, |
| 15 |
# |
| 16 |
# You'll want to edit the url key in riak.conf to point at the interface your |
| 17 |
# riak install is listening on: |
| 18 |
# |
| 19 |
# param url { |
| 20 |
# value = "http://10.0.1.123:8098/stats" |
| 21 |
# } |
| 22 |
|
| 23 |
import os |
| 24 |
import sys |
| 25 |
import threading |
| 26 |
import time |
| 27 |
import urllib2 |
| 28 |
import traceback |
| 29 |
import json |
| 30 |
|
| 31 |
descriptors = list() |
| 32 |
Desc_Skel = {} |
| 33 |
_Worker_Thread = None |
| 34 |
_Lock = threading.Lock() # synchronization lock |
| 35 |
Debug = False |
| 36 |
|
| 37 |
|
| 38 |
def dprint(f, *v): |
| 39 |
if Debug: |
| 40 |
print >>sys.stderr, "DEBUG: " + f % v |
| 41 |
|
| 42 |
|
| 43 |
def floatable(str): |
| 44 |
try: |
| 45 |
float(str) |
| 46 |
return True |
| 47 |
except: |
| 48 |
return False |
| 49 |
|
| 50 |
|
| 51 |
class UpdateMetricThread(threading.Thread): |
| 52 |
|
| 53 |
def __init__(self, params): |
| 54 |
threading.Thread.__init__(self) |
| 55 |
self.running = False |
| 56 |
self.shuttingdown = False |
| 57 |
self.refresh_rate = 30 |
| 58 |
if "refresh_rate" in params: |
| 59 |
self.refresh_rate = int(params["refresh_rate"]) |
| 60 |
self.metric = {} |
| 61 |
self.timeout = 10 |
| 62 |
|
| 63 |
self.url = "http://localhost:8098/stats" |
| 64 |
if "url" in params: |
| 65 |
self.url = params["url"] |
| 66 |
self.mp = params["metrix_prefix"] |
| 67 |
|
| 68 |
def shutdown(self): |
| 69 |
self.shuttingdown = True |
| 70 |
if not self.running: |
| 71 |
return |
| 72 |
self.join() |
| 73 |
|
| 74 |
def run(self): |
| 75 |
self.running = True |
| 76 |
|
| 77 |
while not self.shuttingdown: |
| 78 |
_Lock.acquire() |
| 79 |
self.update_metric() |
| 80 |
_Lock.release() |
| 81 |
time.sleep(self.refresh_rate) |
| 82 |
|
| 83 |
self.running = False |
| 84 |
|
| 85 |
def update_metric(self): |
| 86 |
try: |
| 87 |
req = urllib2.Request(url=self.url) |
| 88 |
res = urllib2.urlopen(req) |
| 89 |
stats = res.read() |
| 90 |
dprint("%s", stats) |
| 91 |
json_stats = json.loads(stats) |
| 92 |
for (key, value) in json_stats.iteritems(): |
| 93 |
dprint("%s = %s", key, value) |
| 94 |
if value == 'undefined': |
| 95 |
self.metric[self.mp + '_' + key] = 0 |
| 96 |
else: |
| 97 |
self.metric[self.mp + '_' + key] = value |
| 98 |
except urllib2.URLError: |
| 99 |
traceback.print_exc() |
| 100 |
else: |
| 101 |
res.close() |
| 102 |
|
| 103 |
def metric_of(self, name): |
| 104 |
val = 0 |
| 105 |
mp = name.split("_")[0] |
| 106 |
if name in self.metric: |
| 107 |
_Lock.acquire() |
| 108 |
val = self.metric[name] |
| 109 |
_Lock.release() |
| 110 |
return val |
| 111 |
|
| 112 |
|
| 113 |
def metric_init(params): |
| 114 |
global descriptors, Desc_Skel, _Worker_Thread, Debug |
| 115 |
|
| 116 |
if "metrix_prefix" not in params: |
| 117 |
params["metrix_prefix"] = "riak" |
| 118 |
|
| 119 |
print params |
| 120 |
|
| 121 |
# initialize skeleton of descriptors |
| 122 |
Desc_Skel = { |
| 123 |
'name' : 'XXX', |
| 124 |
'call_back' : metric_of, |
| 125 |
'time_max' : 60, |
| 126 |
'value_type' : 'uint', |
| 127 |
'format' : '%u', |
| 128 |
'units' : 'XXX', |
| 129 |
'slope' : 'XXX', # zero|positive|negative|both |
| 130 |
'description' : 'XXX', |
| 131 |
'groups' : 'riak', |
| 132 |
} |
| 133 |
|
| 134 |
if "refresh_rate" not in params: |
| 135 |
params["refresh_rate"] = 15 |
| 136 |
if "debug" in params: |
| 137 |
Debug = params["debug"] |
| 138 |
dprint("%s", "Debug mode on") |
| 139 |
|
| 140 |
_Worker_Thread = UpdateMetricThread(params) |
| 141 |
_Worker_Thread.start() |
| 142 |
|
| 143 |
# IP:HOSTNAME |
| 144 |
if "spoof_host" in params: |
| 145 |
Desc_Skel["spoof_host"] = params["spoof_host"] |
| 146 |
|
| 147 |
mp = params["metrix_prefix"] |
| 148 |
|
| 149 |
descriptors.append(create_desc(Desc_Skel, { |
| 150 |
"slope": "both", |
| 151 |
"name": mp + "_riak_node_get_fsm_siblings_100", |
| 152 |
})) |
| 153 |
descriptors.append(create_desc(Desc_Skel, { |
| 154 |
"slope": "both", |
| 155 |
"name": mp + "_riak_node_get_fsm_siblings_95", |
| 156 |
})) |
| 157 |
descriptors.append(create_desc(Desc_Skel, { |
| 158 |
"slope": "both", |
| 159 |
"name": mp + "_riak_node_get_fsm_siblings_99", |
| 160 |
})) |
| 161 |
descriptors.append(create_desc(Desc_Skel, { |
| 162 |
"slope": "both", |
| 163 |
"name": mp + "_riak_node_get_fsm_siblings_mean", |
| 164 |
})) |
| 165 |
descriptors.append(create_desc(Desc_Skel, { |
| 166 |
"slope": "both", |
| 167 |
"name": mp + "_riak_node_get_fsm_siblings_median", |
| 168 |
})) |
| 169 |
descriptors.append(create_desc(Desc_Skel, { |
| 170 |
"slope": "both", |
| 171 |
"name": mp + "_executing_mappers", |
| 172 |
})) |
| 173 |
descriptors.append(create_desc(Desc_Skel, { |
| 174 |
"slope": "both", |
| 175 |
"name": mp + "_node_get_fsm_active", |
| 176 |
})) |
| 177 |
descriptors.append(create_desc(Desc_Skel, { |
| 178 |
"slope": "both", |
| 179 |
"name": mp + "_node_get_fsm_active_60s", |
| 180 |
})) |
| 181 |
descriptors.append(create_desc(Desc_Skel, { |
| 182 |
"slope": "both", |
| 183 |
"name": mp + "_node_get_fsm_in_rate", |
| 184 |
})) |
| 185 |
descriptors.append(create_desc(Desc_Skel, { |
| 186 |
"slope": "both", |
| 187 |
"name": mp + "_node_put_fsm_active_60s", |
| 188 |
})) |
| 189 |
descriptors.append(create_desc(Desc_Skel, { |
| 190 |
"slope": "both", |
| 191 |
"name": mp + "_node_put_fsm_in_rate", |
| 192 |
})) |
| 193 |
descriptors.append(create_desc(Desc_Skel, { |
| 194 |
"slope": "both", |
| 195 |
"name": mp + "_node_put_fsm_out_rate", |
| 196 |
})) |
| 197 |
descriptors.append(create_desc(Desc_Skel, { |
| 198 |
"slope": "both", |
| 199 |
"name": mp + "_pipeline_active", |
| 200 |
})) |
| 201 |
descriptors.append(create_desc(Desc_Skel, { |
| 202 |
"slope": "both", |
| 203 |
"name": mp + "_pipeline_create_count", |
| 204 |
})) |
| 205 |
descriptors.append(create_desc(Desc_Skel, { |
| 206 |
"slope": "both", |
| 207 |
"name": mp + "_pipeline_create_error_count", |
| 208 |
})) |
| 209 |
descriptors.append(create_desc(Desc_Skel, { |
| 210 |
"slope": "both", |
| 211 |
"name": mp + "_pipeline_create_error_one", |
| 212 |
})) |
| 213 |
descriptors.append(create_desc(Desc_Skel, { |
| 214 |
"slope": "both", |
| 215 |
"name": mp + "_pipeline_create_one", |
| 216 |
})) |
| 217 |
descriptors.append(create_desc(Desc_Skel, { |
| 218 |
"slope": "both", |
| 219 |
"name": mp + "_index_fsm_active", |
| 220 |
})) |
| 221 |
descriptors.append(create_desc(Desc_Skel, { |
| 222 |
"slope": "both", |
| 223 |
"name": mp + "_index_fsm_create", |
| 224 |
})) |
| 225 |
descriptors.append(create_desc(Desc_Skel, { |
| 226 |
"slope": "both", |
| 227 |
"name": mp + "_index_fsm_create_error", |
| 228 |
})) |
| 229 |
descriptors.append(create_desc(Desc_Skel, { |
| 230 |
"slope": "both", |
| 231 |
"name": mp + "_list_fsm_active", |
| 232 |
})) |
| 233 |
descriptors.append(create_desc(Desc_Skel, { |
| 234 |
"slope": "both", |
| 235 |
"name": mp + "_list_fsm_create", |
| 236 |
})) |
| 237 |
descriptors.append(create_desc(Desc_Skel, { |
| 238 |
"slope": "both", |
| 239 |
"name": mp + "_list_fsm_create_error", |
| 240 |
})) |
| 241 |
descriptors.append(create_desc(Desc_Skel, { |
| 242 |
"slope": "both", |
| 243 |
"name": mp + "_node_get_fsm_out_rate", |
| 244 |
})) |
| 245 |
descriptors.append(create_desc(Desc_Skel, { |
| 246 |
"slope": "both", |
| 247 |
"name": mp + "_node_get_fsm_rejected", |
| 248 |
})) |
| 249 |
descriptors.append(create_desc(Desc_Skel, { |
| 250 |
"slope": "both", |
| 251 |
"name": mp + "_node_get_fsm_rejected_60s", |
| 252 |
})) |
| 253 |
descriptors.append(create_desc(Desc_Skel, { |
| 254 |
"slope": "both", |
| 255 |
"name": mp + "_node_get_fsm_siblings_100", |
| 256 |
})) |
| 257 |
descriptors.append(create_desc(Desc_Skel, { |
| 258 |
"slope": "both", |
| 259 |
"name": mp + "_node_put_fsm_active", |
| 260 |
})) |
| 261 |
descriptors.append(create_desc(Desc_Skel, { |
| 262 |
"slope": "both", |
| 263 |
"name": mp + "_node_put_fsm_rejected", |
| 264 |
})) |
| 265 |
descriptors.append(create_desc(Desc_Skel, { |
| 266 |
"slope": "both", |
| 267 |
"name": mp + "_node_put_fsm_rejected_60s", |
| 268 |
})) |
| 269 |
descriptors.append(create_desc(Desc_Skel, { |
| 270 |
"slope": "both", |
| 271 |
"name": mp + "_read_repairs_primary_notfound_count", |
| 272 |
})) |
| 273 |
descriptors.append(create_desc(Desc_Skel, { |
| 274 |
"slope": "both", |
| 275 |
"name": mp + "_read_repairs_primary_notfound_one", |
| 276 |
})) |
| 277 |
descriptors.append(create_desc(Desc_Skel, { |
| 278 |
"slope": "both", |
| 279 |
"name": mp + "_read_repairs_primary_outofdate_count", |
| 280 |
})) |
| 281 |
descriptors.append(create_desc(Desc_Skel, { |
| 282 |
"slope": "both", |
| 283 |
"name": mp + "_read_repairs_primary_outofdate_one", |
| 284 |
})) |
| 285 |
descriptors.append(create_desc(Desc_Skel, { |
| 286 |
"slope": "both", |
| 287 |
"name": mp + "_rebalance_delay_mean", |
| 288 |
})) |
| 289 |
descriptors.append(create_desc(Desc_Skel, { |
| 290 |
"slope": "both", |
| 291 |
"name": mp + "_rejected_handoffs", |
| 292 |
})) |
| 293 |
descriptors.append(create_desc(Desc_Skel, { |
| 294 |
"slope": "both", |
| 295 |
"name": mp + "_riak_core_stat_ts", |
| 296 |
})) |
| 297 |
descriptors.append(create_desc(Desc_Skel, { |
| 298 |
"slope": "both", |
| 299 |
"name": mp + "_riak_kv_stat_ts", |
| 300 |
})) |
| 301 |
descriptors.append(create_desc(Desc_Skel, { |
| 302 |
"slope": "both", |
| 303 |
"name": mp + "_riak_pipe_stat_ts", |
| 304 |
})) |
| 305 |
descriptors.append(create_desc(Desc_Skel, { |
| 306 |
"slope": "both", |
| 307 |
"name": mp + "_riak_pipe_vnodeq_mean", |
| 308 |
})) |
| 309 |
descriptors.append(create_desc(Desc_Skel, { |
| 310 |
"slope": "both", |
| 311 |
"name": mp + "_rings_reconciled", |
| 312 |
})) |
| 313 |
descriptors.append(create_desc(Desc_Skel, { |
| 314 |
"slope": "both", |
| 315 |
"name": mp + "_vnode_index_refreshes", |
| 316 |
})) |
| 317 |
descriptors.append(create_desc(Desc_Skel, { |
| 318 |
"slope": "both", |
| 319 |
"name": mp + "_node_puts", |
| 320 |
"units": "puts", |
| 321 |
"description": mp + "_node_puts" |
| 322 |
})) |
| 323 |
descriptors.append(create_desc(Desc_Skel, { |
| 324 |
"slope": "both", |
| 325 |
"name": mp + "_sys_logical_processors", |
| 326 |
"format": "%u", |
| 327 |
"value_type": "uint", |
| 328 |
"units": "N", |
| 329 |
"description": mp + "_sys_logical_processors" |
| 330 |
})) |
| 331 |
descriptors.append(create_desc(Desc_Skel, { |
| 332 |
"slope": "positive", |
| 333 |
"name": mp + "_ignored_gossip_total", |
| 334 |
"format": "%u", |
| 335 |
"value_type": "uint", |
| 336 |
"units": "N", |
| 337 |
"description": mp + "_ignored_gossip_total" |
| 338 |
})) |
| 339 |
descriptors.append(create_desc(Desc_Skel, { |
| 340 |
"slope": "both", |
| 341 |
"name": mp + "_vnode_gets", |
| 342 |
"units": "gets", |
| 343 |
"description": mp + "_vnode_gets" |
| 344 |
})) |
| 345 |
descriptors.append(create_desc(Desc_Skel, { |
| 346 |
"slope": "both", |
| 347 |
"name": mp + "_node_get_fsm_objsize_100", |
| 348 |
"format": "%u", |
| 349 |
"value_type": "uint", |
| 350 |
"units": "N", |
| 351 |
"description": mp + "_node_get_fsm_objsize_100" |
| 352 |
})) |
| 353 |
descriptors.append(create_desc(Desc_Skel, { |
| 354 |
"name": mp + "_node_put_fsm_time_mean", |
| 355 |
"units": "microseconds", |
| 356 |
"slope": "both", |
| 357 |
"description": mp + "_node_put_fsm_time_mean", |
| 358 |
})) |
| 359 |
descriptors.append(create_desc(Desc_Skel, { |
| 360 |
"slope": "positive", |
| 361 |
"name": mp + "_node_puts_total", |
| 362 |
"format": "%u", |
| 363 |
"value_type": "uint", |
| 364 |
"units": "N", |
| 365 |
"description": mp + "_node_puts_total" |
| 366 |
})) |
| 367 |
descriptors.append(create_desc(Desc_Skel, { |
| 368 |
"slope": "both", |
| 369 |
"name": mp + "_riak_kv_vnodeq_mean", |
| 370 |
"format": "%u", |
| 371 |
"value_type": "uint", |
| 372 |
"units": "N", |
| 373 |
"description": mp + "_riak_kv_vnodeq_mean" |
| 374 |
})) |
| 375 |
descriptors.append(create_desc(Desc_Skel, { |
| 376 |
"slope": "both", |
| 377 |
"name": mp + "_riak_pipe_vnodes_running", |
| 378 |
"format": "%u", |
| 379 |
"value_type": "uint", |
| 380 |
"units": "N", |
| 381 |
"description": mp + "_riak_pipe_vnodes_running" |
| 382 |
})) |
| 383 |
descriptors.append(create_desc(Desc_Skel, { |
| 384 |
"slope": "both", |
| 385 |
"name": mp + "_vnode_index_writes_postings", |
| 386 |
"format": "%u", |
| 387 |
"value_type": "uint", |
| 388 |
"units": "N", |
| 389 |
"description": mp + "_vnode_index_writes_postings" |
| 390 |
})) |
| 391 |
descriptors.append(create_desc(Desc_Skel, { |
| 392 |
"slope": "positive", |
| 393 |
"name": mp + "_vnode_index_deletes_postings_total", |
| 394 |
"format": "%u", |
| 395 |
"value_type": "uint", |
| 396 |
"units": "N", |
| 397 |
"description": mp + "_vnode_index_deletes_postings_total" |
| 398 |
})) |
| 399 |
descriptors.append(create_desc(Desc_Skel, { |
| 400 |
"slope": "positive", |
| 401 |
"name": mp + "_read_repairs_total", |
| 402 |
"format": "%u", |
| 403 |
"value_type": "uint", |
| 404 |
"units": "N", |
| 405 |
"description": mp + "_read_repairs_total" |
| 406 |
})) |
| 407 |
descriptors.append(create_desc(Desc_Skel, { |
| 408 |
"slope": "both", |
| 409 |
"name": mp + "_precommit_fail", |
| 410 |
"format": "%u", |
| 411 |
"value_type": "uint", |
| 412 |
"units": "N", |
| 413 |
"description": mp + "_precommit_fail" |
| 414 |
})) |
| 415 |
descriptors.append(create_desc(Desc_Skel, { |
| 416 |
"slope": "both", |
| 417 |
"name": mp + "_rebalance_delay_max", |
| 418 |
"format": "%u", |
| 419 |
"value_type": "uint", |
| 420 |
"units": "N", |
| 421 |
"description": mp + "_rebalance_delay_max" |
| 422 |
})) |
| 423 |
descriptors.append(create_desc(Desc_Skel, { |
| 424 |
"slope": "both", |
| 425 |
"name": mp + "_converge_delay_mean", |
| 426 |
"format": "%u", |
| 427 |
"value_type": "uint", |
| 428 |
"units": "N", |
| 429 |
"description": mp + "_converge_delay_mean" |
| 430 |
})) |
| 431 |
descriptors.append(create_desc(Desc_Skel, { |
| 432 |
"slope": "both", |
| 433 |
"name": mp + "_node_get_fsm_time_95", |
| 434 |
"units": "microseconds", |
| 435 |
"description": mp + "_node_get_fsm_time_95" |
| 436 |
})) |
| 437 |
descriptors.append(create_desc(Desc_Skel, { |
| 438 |
"slope": "both", |
| 439 |
"name": mp + "_riak_pipe_vnodeq_median", |
| 440 |
"format": "%u", |
| 441 |
"value_type": "uint", |
| 442 |
"units": "N", |
| 443 |
"description": mp + "_riak_pipe_vnodeq_median" |
| 444 |
})) |
| 445 |
descriptors.append(create_desc(Desc_Skel, { |
| 446 |
"slope": "both", |
| 447 |
"name": mp + "_node_get_fsm_time_99", |
| 448 |
"value_type": "uint", |
| 449 |
"units": "microseconds", |
| 450 |
"description": mp + "_node_get_fsm_time_99" |
| 451 |
})) |
| 452 |
descriptors.append(create_desc(Desc_Skel, { |
| 453 |
"slope": "both", |
| 454 |
"name": mp + "_memory_code", |
| 455 |
"format": "%u", |
| 456 |
"value_type": "uint", |
| 457 |
"units": "N", |
| 458 |
"description": mp + "_memory_code" |
| 459 |
})) |
| 460 |
descriptors.append(create_desc(Desc_Skel, { |
| 461 |
"slope": "both", |
| 462 |
"name": mp + "_sys_smp_support", |
| 463 |
"format": "%u", |
| 464 |
"value_type": "uint", |
| 465 |
"units": "N", |
| 466 |
"description": mp + "_sys_smp_support" |
| 467 |
})) |
| 468 |
descriptors.append(create_desc(Desc_Skel, { |
| 469 |
"slope": "both", |
| 470 |
"name": mp + "_memory_processes_used", |
| 471 |
"format": "%u", |
| 472 |
"value_type": "uint", |
| 473 |
"units": "N", |
| 474 |
"description": mp + "_memory_processes_used" |
| 475 |
})) |
| 476 |
descriptors.append(create_desc(Desc_Skel, { |
| 477 |
"slope": "both", |
| 478 |
"name": mp + "_pbc_active", |
| 479 |
"units": "connections", |
| 480 |
"description": mp + "_pbc_active" |
| 481 |
})) |
| 482 |
descriptors.append(create_desc(Desc_Skel, { |
| 483 |
"slope": "positive", |
| 484 |
"name": mp + "_vnode_index_writes_postings_total", |
| 485 |
"format": "%u", |
| 486 |
"value_type": "uint", |
| 487 |
"units": "N", |
| 488 |
"description": mp + "_vnode_index_writes_postings_total" |
| 489 |
})) |
| 490 |
descriptors.append(create_desc(Desc_Skel, { |
| 491 |
"slope": "positive", |
| 492 |
"name": mp + "_vnode_gets_total", |
| 493 |
"format": "%u", |
| 494 |
"value_type": "uint", |
| 495 |
"units": "N", |
| 496 |
"description": mp + "_vnode_gets_total" |
| 497 |
})) |
| 498 |
descriptors.append(create_desc(Desc_Skel, { |
| 499 |
"slope": "both", |
| 500 |
"name": mp + "_sys_process_count", |
| 501 |
"units": "processes", |
| 502 |
"description": "Erlang processes" |
| 503 |
})) |
| 504 |
descriptors.append(create_desc(Desc_Skel, { |
| 505 |
"slope": "both", |
| 506 |
"name": mp + "_read_repairs", |
| 507 |
"units": "repairs", |
| 508 |
"description": mp + "_read_repairs" |
| 509 |
})) |
| 510 |
descriptors.append(create_desc(Desc_Skel, { |
| 511 |
"slope": "both", |
| 512 |
"name": mp + "_vnode_puts", |
| 513 |
"units": "puts", |
| 514 |
"description": mp + "_vnode_puts" |
| 515 |
})) |
| 516 |
descriptors.append(create_desc(Desc_Skel, { |
| 517 |
"slope": "both", |
| 518 |
"name": mp + "_riak_search_vnodes_running", |
| 519 |
"format": "%u", |
| 520 |
"value_type": "uint", |
| 521 |
"units": "N", |
| 522 |
"description": mp + "_riak_search_vnodes_running" |
| 523 |
})) |
| 524 |
descriptors.append(create_desc(Desc_Skel, { |
| 525 |
"slope": "both", |
| 526 |
"name": mp + "_riak_pipe_vnodeq_min", |
| 527 |
"format": "%u", |
| 528 |
"value_type": "uint", |
| 529 |
"units": "N", |
| 530 |
"description": mp + "_riak_pipe_vnodeq_min" |
| 531 |
})) |
| 532 |
descriptors.append(create_desc(Desc_Skel, { |
| 533 |
"slope": "both", |
| 534 |
"name": mp + "_node_get_fsm_objsize_mean", |
| 535 |
"format": "%u", |
| 536 |
"value_type": "uint", |
| 537 |
"units": "N", |
| 538 |
"description": mp + "_node_get_fsm_objsize_mean" |
| 539 |
})) |
| 540 |
descriptors.append(create_desc(Desc_Skel, { |
| 541 |
"slope": "both", |
| 542 |
"name": mp + "_cpu_nprocs", |
| 543 |
"format": "%u", |
| 544 |
"value_type": "uint", |
| 545 |
"units": "N", |
| 546 |
"description": mp + "_cpu_nprocs" |
| 547 |
})) |
| 548 |
descriptors.append(create_desc(Desc_Skel, { |
| 549 |
"slope": "both", |
| 550 |
"name": mp + "_node_put_fsm_time_100", |
| 551 |
"units": "microseconds", |
| 552 |
"description": mp + "_node_put_fsm_time_100" |
| 553 |
})) |
| 554 |
descriptors.append(create_desc(Desc_Skel, { |
| 555 |
"slope": "both", |
| 556 |
"name": mp + "_mem_total", |
| 557 |
"format": "%.1f", |
| 558 |
"value_type": "float", |
| 559 |
"units": "bytes", |
| 560 |
"description": mp + "_mem_total" |
| 561 |
})) |
| 562 |
descriptors.append(create_desc(Desc_Skel, { |
| 563 |
"slope": "both", |
| 564 |
"name": mp + "_riak_search_vnodeq_mean", |
| 565 |
"format": "%u", |
| 566 |
"value_type": "uint", |
| 567 |
"units": "N", |
| 568 |
"description": mp + "_riak_search_vnodeq_mean" |
| 569 |
})) |
| 570 |
descriptors.append(create_desc(Desc_Skel, { |
| 571 |
"slope": "both", |
| 572 |
"name": mp + "_node_get_fsm_siblings_median", |
| 573 |
"format": "%u", |
| 574 |
"value_type": "uint", |
| 575 |
"units": "N", |
| 576 |
"description": mp + "_node_get_fsm_siblings_median" |
| 577 |
})) |
| 578 |
descriptors.append(create_desc(Desc_Skel, { |
| 579 |
"slope": "both", |
| 580 |
"name": mp + "_riak_search_vnodeq_max", |
| 581 |
"format": "%u", |
| 582 |
"value_type": "uint", |
| 583 |
"units": "N", |
| 584 |
"description": mp + "_riak_search_vnodeq_max" |
| 585 |
})) |
| 586 |
descriptors.append(create_desc(Desc_Skel, { |
| 587 |
"slope": "both", |
| 588 |
"name": mp + "_sys_threads_enabled", |
| 589 |
"format": "%u", |
| 590 |
"value_type": "uint", |
| 591 |
"units": "N", |
| 592 |
"description": mp + "_sys_threads_enabled" |
| 593 |
})) |
| 594 |
descriptors.append(create_desc(Desc_Skel, { |
| 595 |
"slope": "both", |
| 596 |
"name": mp + "_vnode_index_writes", |
| 597 |
"format": "%u", |
| 598 |
"value_type": "uint", |
| 599 |
"units": "N", |
| 600 |
"description": mp + "_vnode_index_writes" |
| 601 |
})) |
| 602 |
descriptors.append(create_desc(Desc_Skel, { |
| 603 |
"slope": "positive", |
| 604 |
"name": mp + "_memory_total", |
| 605 |
"format": "%u", |
| 606 |
"value_type": "uint", |
| 607 |
"units": "N", |
| 608 |
"description": mp + "_memory_total" |
| 609 |
})) |
| 610 |
descriptors.append(create_desc(Desc_Skel, { |
| 611 |
"slope": "both", |
| 612 |
"name": mp + "_riak_pipe_vnodeq_max", |
| 613 |
"format": "%u", |
| 614 |
"value_type": "uint", |
| 615 |
"units": "N", |
| 616 |
"description": mp + "_riak_pipe_vnodeq_max" |
| 617 |
})) |
| 618 |
descriptors.append(create_desc(Desc_Skel, { |
| 619 |
"slope": "both", |
| 620 |
"name": mp + "_vnode_index_deletes_postings", |
| 621 |
"format": "%u", |
| 622 |
"value_type": "uint", |
| 623 |
"units": "N", |
| 624 |
"description": mp + "_vnode_index_deletes_postings" |
| 625 |
})) |
| 626 |
descriptors.append(create_desc(Desc_Skel, { |
| 627 |
"slope": "both", |
| 628 |
"name": mp + "_node_get_fsm_time_mean", |
| 629 |
"units": "microseconds", |
| 630 |
"description": "Mean for riak_kv_get_fsm calls" |
| 631 |
})) |
| 632 |
descriptors.append(create_desc(Desc_Skel, { |
| 633 |
"slope": "both", |
| 634 |
"name": mp + "_ring_num_partitions", |
| 635 |
"units": "vnodes", |
| 636 |
"description": mp + "_ring_num_partitions" |
| 637 |
})) |
| 638 |
descriptors.append(create_desc(Desc_Skel, { |
| 639 |
"slope": "both", |
| 640 |
"name": mp + "_riak_search_vnodeq_min", |
| 641 |
"format": "%u", |
| 642 |
"value_type": "uint", |
| 643 |
"units": "N", |
| 644 |
"description": mp + "_riak_search_vnodeq_min" |
| 645 |
})) |
| 646 |
descriptors.append(create_desc(Desc_Skel, { |
| 647 |
"slope": "positive", |
| 648 |
"name": mp + "_vnode_index_reads_total", |
| 649 |
"format": "%u", |
| 650 |
"value_type": "uint", |
| 651 |
"units": "N", |
| 652 |
"description": mp + "_vnode_index_reads_total" |
| 653 |
})) |
| 654 |
descriptors.append(create_desc(Desc_Skel, { |
| 655 |
"slope": "both", |
| 656 |
"name": mp + "_node_get_fsm_siblings_99", |
| 657 |
"format": "%u", |
| 658 |
"value_type": "uint", |
| 659 |
"units": "N", |
| 660 |
"description": mp + "_node_get_fsm_siblings_99" |
| 661 |
})) |
| 662 |
descriptors.append(create_desc(Desc_Skel, { |
| 663 |
"slope": "both", |
| 664 |
"name": mp + "_mem_allocated", |
| 665 |
"format": "%.1f", |
| 666 |
"value_type": "float", |
| 667 |
"units": "bytes", |
| 668 |
"description": mp + "_mem_allocated" |
| 669 |
})) |
| 670 |
descriptors.append(create_desc(Desc_Skel, { |
| 671 |
"slope": "both", |
| 672 |
"name": mp + "_node_get_fsm_siblings_95", |
| 673 |
"format": "%u", |
| 674 |
"value_type": "uint", |
| 675 |
"units": "N", |
| 676 |
"description": mp + "_node_get_fsm_siblings_95" |
| 677 |
})) |
| 678 |
descriptors.append(create_desc(Desc_Skel, { |
| 679 |
"slope": "both", |
| 680 |
"name": mp + "_node_get_fsm_objsize_95", |
| 681 |
"format": "%u", |
| 682 |
"value_type": "uint", |
| 683 |
"units": "N", |
| 684 |
"description": mp + "_node_get_fsm_objsize_95" |
| 685 |
})) |
| 686 |
descriptors.append(create_desc(Desc_Skel, { |
| 687 |
"slope": "both", |
| 688 |
"name": mp + "_node_put_fsm_time_median", |
| 689 |
"units": "microseconds", |
| 690 |
"description": mp + "_node_put_fsm_time_median" |
| 691 |
})) |
| 692 |
descriptors.append(create_desc(Desc_Skel, { |
| 693 |
"slope": "both", |
| 694 |
"name": mp + "_memory_processes", |
| 695 |
"format": "%u", |
| 696 |
"value_type": "uint", |
| 697 |
"units": "N", |
| 698 |
"description": mp + "_memory_processes" |
| 699 |
})) |
| 700 |
descriptors.append(create_desc(Desc_Skel, { |
| 701 |
"slope": "positive", |
| 702 |
"name": mp + "_riak_search_vnodeq_total", |
| 703 |
"format": "%u", |
| 704 |
"value_type": "uint", |
| 705 |
"units": "N", |
| 706 |
"description": mp + "_riak_search_vnodeq_total" |
| 707 |
})) |
| 708 |
descriptors.append(create_desc(Desc_Skel, { |
| 709 |
"slope": "both", |
| 710 |
"name": mp + "_node_get_fsm_objsize_99", |
| 711 |
"format": "%u", |
| 712 |
"value_type": "uint", |
| 713 |
"units": "N", |
| 714 |
"description": mp + "_node_get_fsm_objsize_99" |
| 715 |
})) |
| 716 |
descriptors.append(create_desc(Desc_Skel, { |
| 717 |
"slope": "both", |
| 718 |
"name": mp + "_memory_system", |
| 719 |
"format": "%u", |
| 720 |
"value_type": "uint", |
| 721 |
"units": "N", |
| 722 |
"description": mp + "_memory_system" |
| 723 |
})) |
| 724 |
descriptors.append(create_desc(Desc_Skel, { |
| 725 |
"slope": "both", |
| 726 |
"name": mp + "_sys_global_heaps_size", |
| 727 |
"format": "%u", |
| 728 |
"value_type": "uint", |
| 729 |
"units": "N", |
| 730 |
"description": mp + "_sys_global_heaps_size" |
| 731 |
})) |
| 732 |
descriptors.append(create_desc(Desc_Skel, { |
| 733 |
"slope": "both", |
| 734 |
"name": mp + "_gossip_received", |
| 735 |
"format": "%u", |
| 736 |
"value_type": "uint", |
| 737 |
"units": "N", |
| 738 |
"description": mp + "_gossip_received" |
| 739 |
})) |
| 740 |
descriptors.append(create_desc(Desc_Skel, { |
| 741 |
"slope": "both", |
| 742 |
"name": mp + "_node_get_fsm_time_median", |
| 743 |
"units": "microseconds", |
| 744 |
"description": mp + "_node_get_fsm_time_median" |
| 745 |
})) |
| 746 |
descriptors.append(create_desc(Desc_Skel, { |
| 747 |
"slope": "positive", |
| 748 |
"name": mp + "_vnode_index_deletes_total", |
| 749 |
"format": "%u", |
| 750 |
"value_type": "uint", |
| 751 |
"units": "N", |
| 752 |
"description": mp + "_vnode_index_deletes_total" |
| 753 |
})) |
| 754 |
descriptors.append(create_desc(Desc_Skel, { |
| 755 |
"slope": "both", |
| 756 |
"name": mp + "_riak_kv_vnodeq_max", |
| 757 |
"format": "%u", |
| 758 |
"value_type": "uint", |
| 759 |
"units": "N", |
| 760 |
"description": mp + "_riak_kv_vnodeq_max" |
| 761 |
})) |
| 762 |
descriptors.append(create_desc(Desc_Skel, { |
| 763 |
"slope": "both", |
| 764 |
"name": mp + "_riak_kv_vnodeq_min", |
| 765 |
"format": "%u", |
| 766 |
"value_type": "uint", |
| 767 |
"units": "N", |
| 768 |
"description": mp + "_riak_kv_vnodeq_min" |
| 769 |
})) |
| 770 |
descriptors.append(create_desc(Desc_Skel, { |
| 771 |
"slope": "both", |
| 772 |
"name": mp + "_node_gets", |
| 773 |
"units": "gets", |
| 774 |
"description": mp + "_node_gets" |
| 775 |
})) |
| 776 |
descriptors.append(create_desc(Desc_Skel, { |
| 777 |
"slope": "both", |
| 778 |
"name": mp + "_riak_kv_vnodeq_median", |
| 779 |
"format": "%u", |
| 780 |
"value_type": "uint", |
| 781 |
"units": "N", |
| 782 |
"description": mp + "_riak_kv_vnodeq_median" |
| 783 |
})) |
| 784 |
descriptors.append(create_desc(Desc_Skel, { |
| 785 |
"slope": "both", |
| 786 |
"name": mp + "_postcommit_fail", |
| 787 |
"format": "%u", |
| 788 |
"value_type": "uint", |
| 789 |
"units": "N", |
| 790 |
"description": mp + "_postcommit_fail" |
| 791 |
})) |
| 792 |
descriptors.append(create_desc(Desc_Skel, { |
| 793 |
"slope": "both", |
| 794 |
"name": mp + "_riak_search_vnodeq_median", |
| 795 |
"format": "%u", |
| 796 |
"value_type": "uint", |
| 797 |
"units": "N", |
| 798 |
"description": mp + "_riak_search_vnodeq_median" |
| 799 |
})) |
| 800 |
descriptors.append(create_desc(Desc_Skel, { |
| 801 |
"slope": "both", |
| 802 |
"name": mp + "_sys_wordsize", |
| 803 |
"format": "%u", |
| 804 |
"value_type": "uint", |
| 805 |
"units": "N", |
| 806 |
"description": mp + "_sys_wordsize" |
| 807 |
})) |
| 808 |
descriptors.append(create_desc(Desc_Skel, { |
| 809 |
"slope": "both", |
| 810 |
"name": mp + "_riak_kv_vnodes_running", |
| 811 |
"format": "%u", |
| 812 |
"value_type": "uint", |
| 813 |
"units": "N", |
| 814 |
"description": mp + "_riak_kv_vnodes_running" |
| 815 |
})) |
| 816 |
descriptors.append(create_desc(Desc_Skel, { |
| 817 |
"slope": "both", |
| 818 |
"name": mp + "_node_put_fsm_time_95", |
| 819 |
"units": "microseconds", |
| 820 |
"description": mp + "_node_put_fsm_time_95", |
| 821 |
})) |
| 822 |
descriptors.append(create_desc(Desc_Skel, { |
| 823 |
"slope": "positive", |
| 824 |
"name": mp + "_rings_reconciled_total", |
| 825 |
"format": "%u", |
| 826 |
"value_type": "uint", |
| 827 |
"units": "N", |
| 828 |
"description": mp + "_rings_reconciled_total" |
| 829 |
})) |
| 830 |
descriptors.append(create_desc(Desc_Skel, { |
| 831 |
"slope": "both", |
| 832 |
"name": mp + "_rebalance_delay_min", |
| 833 |
"format": "%u", |
| 834 |
"value_type": "uint", |
| 835 |
"units": "N", |
| 836 |
"description": mp + "_rebalance_delay_min" |
| 837 |
})) |
| 838 |
descriptors.append(create_desc(Desc_Skel, { |
| 839 |
"slope": "both", |
| 840 |
"name": mp + "_node_put_fsm_time_99", |
| 841 |
"units": "microseconds", |
| 842 |
"description": mp + "_node_put_fsm_time_99", |
| 843 |
})) |
| 844 |
descriptors.append(create_desc(Desc_Skel, { |
| 845 |
"slope": "both", |
| 846 |
"name": mp + "_ring_creation_size", |
| 847 |
"units": "vnodes", |
| 848 |
"description": mp + "_ring_creation_size" |
| 849 |
})) |
| 850 |
descriptors.append(create_desc(Desc_Skel, { |
| 851 |
"slope": "both", |
| 852 |
"name": mp + "_cpu_avg1", |
| 853 |
"format": "%u", |
| 854 |
"value_type": "uint", |
| 855 |
"units": "N", |
| 856 |
"description": mp + "_cpu_avg1" |
| 857 |
})) |
| 858 |
descriptors.append(create_desc(Desc_Skel, { |
| 859 |
"slope": "both", |
| 860 |
"name": mp + "_cpu_avg5", |
| 861 |
"format": "%u", |
| 862 |
"value_type": "uint", |
| 863 |
"units": "N", |
| 864 |
"description": mp + "_cpu_avg5" |
| 865 |
})) |
| 866 |
descriptors.append(create_desc(Desc_Skel, { |
| 867 |
"slope": "positive", |
| 868 |
"name": mp + "_pbc_connects_total", |
| 869 |
"format": "%u", |
| 870 |
"value_type": "uint", |
| 871 |
"units": "N", |
| 872 |
"description": mp + "_pbc_connects_total" |
| 873 |
})) |
| 874 |
descriptors.append(create_desc(Desc_Skel, { |
| 875 |
"slope": "both", |
| 876 |
"name": mp + "_memory_binary", |
| 877 |
"format": "%u", |
| 878 |
"value_type": "uint", |
| 879 |
"units": "N", |
| 880 |
"description": mp + "_memory_binary" |
| 881 |
})) |
| 882 |
descriptors.append(create_desc(Desc_Skel, { |
| 883 |
"slope": "positive", |
| 884 |
"name": mp + "_coord_redirs_total", |
| 885 |
"format": "%u", |
| 886 |
"value_type": "uint", |
| 887 |
"units": "N", |
| 888 |
"description": mp + "_coord_redirs_total" |
| 889 |
})) |
| 890 |
descriptors.append(create_desc(Desc_Skel, { |
| 891 |
"slope": "positive", |
| 892 |
"name": mp + "_riak_pipe_vnodeq_total", |
| 893 |
"format": "%u", |
| 894 |
"value_type": "uint", |
| 895 |
"units": "N", |
| 896 |
"description": mp + "_riak_pipe_vnodeq_total" |
| 897 |
})) |
| 898 |
descriptors.append(create_desc(Desc_Skel, { |
| 899 |
"slope": "positive", |
| 900 |
"name": mp + "_node_gets_total", |
| 901 |
"format": "%u", |
| 902 |
"value_type": "uint", |
| 903 |
"units": "N", |
| 904 |
"description": mp + "_node_gets_total" |
| 905 |
})) |
| 906 |
descriptors.append(create_desc(Desc_Skel, { |
| 907 |
"slope": "positive", |
| 908 |
"name": mp + "_vnode_puts_total", |
| 909 |
"format": "%u", |
| 910 |
"value_type": "uint", |
| 911 |
"units": "N", |
| 912 |
"description": mp + "_vnode_puts_total" |
| 913 |
})) |
| 914 |
descriptors.append(create_desc(Desc_Skel, { |
| 915 |
"slope": "both", |
| 916 |
"name": mp + "_memory_atom", |
| 917 |
"format": "%u", |
| 918 |
"value_type": "uint", |
| 919 |
"units": "N", |
| 920 |
"description": mp + "_memory_atom" |
| 921 |
})) |
| 922 |
descriptors.append(create_desc(Desc_Skel, { |
| 923 |
"slope": "both", |
| 924 |
"name": mp + "_cpu_avg15", |
| 925 |
"format": "%u", |
| 926 |
"value_type": "uint", |
| 927 |
"units": "N", |
| 928 |
"description": mp + "_cpu_avg15" |
| 929 |
})) |
| 930 |
descriptors.append(create_desc(Desc_Skel, { |
| 931 |
"slope": "both", |
| 932 |
"name": mp + "_node_get_fsm_objsize_median", |
| 933 |
"format": "%u", |
| 934 |
"value_type": "uint", |
| 935 |
"units": "N", |
| 936 |
"description": mp + "_node_get_fsm_objsize_median" |
| 937 |
})) |
| 938 |
descriptors.append(create_desc(Desc_Skel, { |
| 939 |
"slope": "both", |
| 940 |
"name": mp + "_node_get_fsm_siblings_mean", |
| 941 |
"format": "%u", |
| 942 |
"value_type": "uint", |
| 943 |
"units": "N", |
| 944 |
"description": mp + "_node_get_fsm_siblings_mean" |
| 945 |
})) |
| 946 |
descriptors.append(create_desc(Desc_Skel, { |
| 947 |
"slope": "both", |
| 948 |
"name": mp + "_converge_delay_min", |
| 949 |
"format": "%u", |
| 950 |
"value_type": "uint", |
| 951 |
"units": "N", |
| 952 |
"description": mp + "_converge_delay_min" |
| 953 |
})) |
| 954 |
descriptors.append(create_desc(Desc_Skel, { |
| 955 |
"slope": "both", |
| 956 |
"name": mp + "_node_get_fsm_time_100", |
| 957 |
"units": "microseconds", |
| 958 |
"description": mp + "_node_get_fsm_time_100" |
| 959 |
})) |
| 960 |
descriptors.append(create_desc(Desc_Skel, { |
| 961 |
"slope": "both", |
| 962 |
"name": mp + "_converge_delay_max", |
| 963 |
"format": "%u", |
| 964 |
"value_type": "uint", |
| 965 |
"units": "N", |
| 966 |
"description": mp + "_converge_delay_max" |
| 967 |
})) |
| 968 |
descriptors.append(create_desc(Desc_Skel, { |
| 969 |
"slope": "both", |
| 970 |
"name": mp + "_converge_delay_last", |
| 971 |
"format": "%u", |
| 972 |
"value_type": "uint", |
| 973 |
"units": "N", |
| 974 |
"description": mp + "_converge_delay_last" |
| 975 |
})) |
| 976 |
descriptors.append(create_desc(Desc_Skel, { |
| 977 |
"slope": "both", |
| 978 |
"name": mp + "_rebalance_delay_last", |
| 979 |
"format": "%u", |
| 980 |
"value_type": "uint", |
| 981 |
"units": "N", |
| 982 |
"description": mp + "_rebalance_delay_last" |
| 983 |
})) |
| 984 |
descriptors.append(create_desc(Desc_Skel, { |
| 985 |
"slope": "both", |
| 986 |
"name": mp + "_vnode_index_deletes", |
| 987 |
"format": "%u", |
| 988 |
"value_type": "uint", |
| 989 |
"units": "N", |
| 990 |
"description": mp + "_vnode_index_deletes" |
| 991 |
})) |
| 992 |
descriptors.append(create_desc(Desc_Skel, { |
| 993 |
"slope": "positive", |
| 994 |
"name": mp + "_riak_kv_vnodeq_total", |
| 995 |
"format": "%u", |
| 996 |
"value_type": "uint", |
| 997 |
"units": "N", |
| 998 |
"description": mp + "_riak_kv_vnodeq_total" |
| 999 |
})) |
| 1000 |
descriptors.append(create_desc(Desc_Skel, { |
| 1001 |
"slope": "both", |
| 1002 |
"name": mp + "_handoff_timeouts", |
| 1003 |
"format": "%u", |
| 1004 |
"value_type": "uint", |
| 1005 |
"units": "N", |
| 1006 |
"description": mp + "_handoff_timeouts" |
| 1007 |
})) |
| 1008 |
descriptors.append(create_desc(Desc_Skel, { |
| 1009 |
"slope": "both", |
| 1010 |
"name": mp + "_vnode_index_reads", |
| 1011 |
"format": "%u", |
| 1012 |
"value_type": "uint", |
| 1013 |
"units": "N", |
| 1014 |
"description": mp + "_vnode_index_reads" |
| 1015 |
})) |
| 1016 |
descriptors.append(create_desc(Desc_Skel, { |
| 1017 |
"slope": "both", |
| 1018 |
"name": mp + "_sys_thread_pool_size", |
| 1019 |
"format": "%u", |
| 1020 |
"value_type": "uint", |
| 1021 |
"units": "N", |
| 1022 |
"description": mp + "_sys_thread_pool_size" |
| 1023 |
})) |
| 1024 |
descriptors.append(create_desc(Desc_Skel, { |
| 1025 |
"slope": "both", |
| 1026 |
"name": mp + "_pbc_connects", |
| 1027 |
"format": "%u", |
| 1028 |
"value_type": "uint", |
| 1029 |
"units": "N", |
| 1030 |
"description": mp + "_pbc_connects" |
| 1031 |
})) |
| 1032 |
|
| 1033 |
return descriptors |
| 1034 |
|
| 1035 |
|
| 1036 |
def create_desc(skel, prop): |
| 1037 |
d = skel.copy() |
| 1038 |
for k, v in prop.iteritems(): |
| 1039 |
d[k] = v |
| 1040 |
return d |
| 1041 |
|
| 1042 |
|
| 1043 |
def metric_of(name): |
| 1044 |
return _Worker_Thread.metric_of(name) |
| 1045 |
|
| 1046 |
|
| 1047 |
def metric_cleanup(): |
| 1048 |
_Worker_Thread.shutdown() |
| 1049 |
|
| 1050 |
|
| 1051 |
if __name__ == '__main__': |
| 1052 |
try: |
| 1053 |
params = { |
| 1054 |
"debug": True, |
| 1055 |
} |
| 1056 |
metric_init(params) |
| 1057 |
while True: |
| 1058 |
for d in descriptors: |
| 1059 |
v = d['call_back'](d['name']) |
| 1060 |
print ('value for %s is ' + d['format']) % (d['name'], v) |
| 1061 |
time.sleep(5) |
| 1062 |
except KeyboardInterrupt: |
| 1063 |
time.sleep(0.2) |
| 1064 |
os._exit(1) |
| 1065 |
except: |
| 1066 |
traceback.print_exc() |
| 1067 |
os._exit(1) |