Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid to apply same method twice

  • Loading branch information...
commit 1d78356a09fc1ea88b9992248aff4cf6951b2405 1 parent 321fbce
@bcui6611 bcui6611 authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 diskqueue_stats.py
View
20 diskqueue_stats.py
@@ -84,8 +84,9 @@ class ReplicationTrend:
def run(self, accessor, scale, threshold=None):
result = {}
cluster = 0
- if threshold.has_key("ReplicationTrend"):
- threshold_val = threshold["ReplicationTrend"]
+ print accessor["type"]
+ if threshold.has_key(accessor["name"]):
+ threshold_val = threshold[accessor["name"]]
else:
threshold_val = accessor["threshold"]
for bucket, stats_info in stats_buffer.buckets.iteritems():
@@ -113,19 +114,20 @@ def run(self, accessor, scale, threshold=None):
else:
ratio = 100.0 * replica[1] / active[1]
delta = int(replica[1])
- if ratio > threshold_val["percentage"]["high"]:
+ if accessor["type"] == "percentage" and ratio > threshold_val["percentage"]["high"]:
symptom = accessor["symptom"].format(util.pretty_float(ratio), threshold_val["percentage"]["high"])
num_error.append({"node":active[0], "value": symptom})
res.append((active[0], util.pretty_float(ratio) + "%"))
- elif delta > threshold_val["number"]["high"]:
+ print num_error
+ elif accessor["type"] == "number" and delta > threshold_val["number"]["high"]:
symptom = accessor["symptom"].format(util.number_label(delta), util.number_label(threshold_val["number"]["high"]))
num_error.append({"node":active[0], "value": symptom})
res.append((active[0], int(delta)))
- elif ratio > threshold_val["percentage"]["low"]:
+ elif accessor["type"] == "percentage" and ratio > threshold_val["percentage"]["low"]:
symptom = accessor["symptom"].format(util.pretty_float(ratio), threshold_val["percentage"]["low"])
num_warn.append({"node":active[0], "value": symptom})
res.append((active[0], util.pretty_float(ratio) + "%"))
- elif delta > threshold_val["number"]["low"]:
+ elif accessor["type"] == "number" and delta > threshold_val["number"]["low"]:
symptom = accessor["symptom"].format(util.number_label(delta), util.number_label(threshold_val["number"]["low"]))
num_warn.append({"node":active[0], "value": symptom})
res.append((active[0], int(delta)))
@@ -134,11 +136,11 @@ def run(self, accessor, scale, threshold=None):
if active_total > 0:
ratio = replica_total * 100.0 / active_total
cluster += ratio
- if ratio > threshold_val["percentage"]["high"]:
+ if accessor["type"] == "percentage" and ratio > threshold_val["percentage"]["high"]:
symptom = accessor["symptom"].format(util.pretty_float(ratio), threshold_val["percentage"]["high"])
num_error.append({"node":"total", "value": symptom})
res.append(("total", util.pretty_float(ratio) + "%"))
- elif ratio > threshold_val["percentage"]["low"]:
+ elif accessor["type"] == "percentage" and ratio > threshold_val["percentage"]["low"]:
symptom = accessor["symptom"].format(util.pretty_float(ratio), threshold_val["percentage"]["low"])
num_warn.append({"node":"total", "value": symptom})
res.append(("total", util.pretty_float(ratio) + "%"))
@@ -230,6 +232,7 @@ def run(self, accessor, scale, threshold=None):
"counter" : ["curr_items", "ep_tap_total_total_backlog_size"],
"scale" : "hour",
"code" : "ReplicationTrend",
+ "type" : "percentage",
"threshold" : {
"percentage" : {
"low" : 10.0,
@@ -251,6 +254,7 @@ def run(self, accessor, scale, threshold=None):
"counter" : ["curr_items", "ep_tap_total_total_backlog_size"],
"scale" : "hour",
"code" : "ReplicationTrend",
+ "type" : "number",
"threshold" : {
"number" : {
"low" : 50000,
Please sign in to comment.
Something went wrong with that request. Please try again.