Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add more unit for stats values
  • Loading branch information
bcui6611 committed Aug 14, 2012
1 parent c3a4db9 commit 43d8951
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
21 changes: 16 additions & 5 deletions cluster_stats.py
Expand Up @@ -184,7 +184,7 @@ def run(self, accessor, scale, threshold=None):
value = max(0, value)
total.append(value)
if value > thresholdval:
symptom = accessor["symptom"].format(value, thresholdval)
symptom = accessor["symptom"].format(util.pretty_float(value), thresholdval)
num_error.append({"node":node, "value":symptom})
trend.append((node, {"value" : util.pretty_float(value) + "%",
"raw" : vals,
Expand Down Expand Up @@ -466,7 +466,8 @@ def run(self, accessor, scale, threshold=None):
for key, value in stats_info.iteritems():
if key == accessor["counter"]:
if accessor.has_key("threshold") and not isinstance(value, dict):
if int(value) > threshold_val:
value = int(value)
if value > threshold_val:
symptom = ""
if accessor.has_key("unit"):
if accessor["unit"] == "time":
Expand All @@ -483,7 +484,7 @@ def run(self, accessor, scale, threshold=None):
if accessor["unit"] == "time":
trend.append((node, {"value":util.time_label(value), "raw":value}))
elif accessor["unit"] == "size":
trend.append((node, {"value":util.size_label(int(value)), "raw":value}))
trend.append((node, {"value":util.size_label(value), "raw":value}))
else:
trend.append((node, value))
if len(num_error) > 0:
Expand All @@ -510,7 +511,15 @@ def run(self, accessor, scale, threshold=None):
num_error.append({"node":node, "value": accessor["symptom"]})
else:
if value > threshold_val:
symptom = accessor["symptom"].format(value, threshold_val)
if accessor.has_key("unit"):
if accessor["unit"] == "time":
symptom = accessor["symptom"].format(util.time_label(int(value)), util.time_label(threshold_val))
elif accessor["unit"] == "size":
symptom = accessor["symptom"].format(util.size_label(int(value)), util.size_label(threshold_val))
else:
symptom = accessor["symptom"].format(value, threshold_val)
else:
symptom = accessor["symptom"].format(value, threshold_val)
num_error.append({"node":node, "value": symptom})
if len(num_error) > 0:
result[bucket] = {"error" : num_error}
Expand Down Expand Up @@ -595,7 +604,7 @@ def run(self, accessor, scale, threshold=None):
{
"name" : "cacheMissRatio",
"description" : "Cache miss ratio",
"symptom" : "Cache miss ratio '{0}' is higher than threshold '{1}'",
"symptom" : "Cache miss ratio '{0}%' is higher than threshold '{1}%'",
"counter" : "ep_cache_miss_rate",
"scale" : "hour",
"code" : "CacheMissRatio",
Expand Down Expand Up @@ -861,6 +870,7 @@ def run(self, accessor, scale, threshold=None):
"description" : "Average item loaded time",
"counter" : "ep_bg_load_avg",
"code" : "EPEnginePerformance",
"unit" : "time",
"threshold" : 100,
"symptom" : "Average time '{0}' for items to be loaded is slower than '{1}'",
"formula" : "Avg(ep_bg_load_avg) > threshold",
Expand All @@ -870,6 +880,7 @@ def run(self, accessor, scale, threshold=None):
"description" : "Average item waited time",
"counter" : "ep_bg_wait_avg",
"code" : "EPEnginePerformance",
"unit" : "time",
"threshold" : 100,
"symptom" : "Average wait time '{0}' for items to be serviced by dispatcher is slower than '{1}'",
"formula" : "Avg(ep_bg_wait_avg) > threshold",
Expand Down
10 changes: 5 additions & 5 deletions diskqueue_stats.py
Expand Up @@ -56,11 +56,11 @@ def run(self, accessor, scale, threshold=None):
for node, vals in nodeStats.iteritems():
a, b = util.linreg(timestamps, vals)
if a > threshold_val["high"]:
symptom = accessor["symptom"].format(util.pretty_float(a), threshold_val["high"])
symptom = accessor["symptom"].format(util.pretty_float(a, 3), threshold_val["high"])
trend_error.append({"node":node, "level":"red", "value":symptom})
res.append((node, util.pretty_float(a)))
elif a > threshold_val["low"]:
symptom = accessor["symptom"].format(util.pretty_float(a), threshold_val["low"])
symptom = accessor["symptom"].format(util.pretty_float(a, 3), threshold_val["low"])
trend_warn.append({"node":node, "level":"yellow", "value":symptom})
res.append((node, util.pretty_float(a)))
if len(trend_error) > 0:
Expand Down Expand Up @@ -102,21 +102,21 @@ def run(self, accessor, scale, threshold=None):
res.append((active[0], 0))
else:
ratio = 100.0 * replica[1] / active[1]
delta = replica[1]
delta = int(replica[1])
if 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"]:
symptom = accessor["symptom"].format(int(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"]:
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"]:
symptom = accessor["symptom"].format(int(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)))
active_total += active[1]
Expand Down
2 changes: 1 addition & 1 deletion prescription.py
Expand Up @@ -38,7 +38,7 @@
"action" : "Replace problem node. If issue persists, please contact support@couchbase.com",
},
"EPEnginePerformance" : {
"cause" : "Poor engine Key Performance Indicators",
"cause" : "Poor ep-engine key performance indicators",
"impact" : "To be defined",
"action" : "Please contact support@couchbase.com",
},
Expand Down

0 comments on commit 43d8951

Please sign in to comment.