def run(self, accessor): result = {} cluster = 0 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 = [] total = 0 data = [] num_error = [] for node, vals in nodeStats.iteritems(): #a, b = util.linreg(timestamps, vals) value = sum(vals) / samplesCount total += value if value > accessor["threshold"]: num_error.append({"node":node, "value":value}) trend.append((node, util.pretty_float(value))) data.append(value) total /= len(nodeStats) trend.append(("total", util.pretty_float(total))) trend.append(("variance", util.two_pass_variance(data))) if len(num_error) > 0: trend.append(("error", num_error)) cluster += total result[bucket] = trend if len(stats_buffer.buckets) > 0: result["cluster"] = util.pretty_float(cluster / len(stats_buffer.buckets)) return result
def run(self, accessor, threshold=None): result = {} cluster = 0 if threshold.has_key("ActiveReplicaResidentRatio"): threshold_val = threshold["ActiveReplicaResidentRatio"][accessor["name"]] else: threshold_val = accessor["threshold"] 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 = [] total = 0 data = [] num_error = [] for node, vals in nodeStats.iteritems(): #a, b = util.linreg(timestamps, vals) if samplesCount > 0: value = sum(vals) / samplesCount else: value = 0 total += value if value > 0 and value < threshold_val: symptom = accessor["symptom"].format(util.pretty_float(value) + "%", util.pretty_float(threshold_val) + "%") num_error.append({"node":node, "value":symptom}) trend.append((node, util.pretty_float(value) + "%")) data.append(value) if len(nodeStats) > 0: total /= len(nodeStats) trend.append(("total", util.pretty_float(total) + "%")) if total > 0 and total < threshold_val: symptom = accessor["symptom"].format(util.pretty_float(total) + "%", util.pretty_float(threshold_val) + "%") num_error.append({"node": "total", "value":symptom}) trend.append(("variance", util.two_pass_variance(data))) if len(num_error) > 0: trend.append(("error", num_error)) cluster += total result[bucket] = trend if len(stats_buffer.buckets) > 0: result["cluster"] = util.pretty_float(cluster / len(stats_buffer.buckets)) + "%" return result
def run(self, accessor): result = {} cluster = 0 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 = [] total = 0 data = [] for node, vals in nodeStats.iteritems(): avg = sum(vals) / samplesCount trend.append((node, util.size_label(avg))) data.append(avg) #print data trend.append(("variance", util.two_pass_variance(data))) result[bucket] = trend return result