summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 589c5f2)
raw | patch | inline | side by side (parent: 589c5f2)
author | Florian Forster <octo@huhu.verplant.org> | |
Thu, 13 Jan 2011 07:57:24 +0000 (08:57 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Thu, 13 Jan 2011 07:57:24 +0000 (08:57 +0100) |
Joey Hess has reported a problem when creating notifications from
percentage thresholds. Because the (percentage) minimum value is
compared to the (raw) DS value, the following message is possible:
Message: Host XXX, plugin df type df (instance root): Data source
"free" is currently 1773072384.000000. That is above the warning
threshold of nan%.
A new section will handle this case correctly. In the inverted case, the
problem should not exist.
percentage thresholds. Because the (percentage) minimum value is
compared to the (raw) DS value, the following message is possible:
Message: Host XXX, plugin df type df (instance root): Data source
"free" is currently 1773072384.000000. That is above the warning
threshold of nan%.
A new section will handle this case correctly. In the inverted case, the
problem should not exist.
src/utils_threshold.c | patch | blob | history |
diff --git a/src/utils_threshold.c b/src/utils_threshold.c
index 090cc75206f9c47acdde32dc5c6821bca67201aa..b14c79b5c6005bfdb86b9a3abfebb266a592897e 100644 (file)
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
}
}
+ else if (th->flags & UT_FLAG_PERCENTAGE)
+ {
+ gauge_t value;
+ gauge_t sum;
+ int i;
+
+ sum = 0.0;
+ for (i = 0; i < vl->values_len; i++)
+ {
+ if (isnan (values[i]))
+ continue;
+
+ sum += values[i];
+ }
+
+ if (sum == 0.0)
+ value = NAN;
+ else
+ value = 100.0 * values[ds_index] / sum;
+
+ status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
+ "%g (%.2f%%). That is %s the %s threshold of %.2f%%.",
+ ds->ds[ds_index].name, values[ds_index], value,
+ (value < min) ? "below" : "above",
+ (state == STATE_ERROR) ? "failure" : "warning",
+ (value < min) ? min : max);
+ }
else /* is not inverted */
{
status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
- "%f. That is %s the %s threshold of %f%s.",
+ "%f. That is %s the %s threshold of %f.",
ds->ds[ds_index].name, values[ds_index],
(values[ds_index] < min) ? "below" : "above",
(state == STATE_ERROR) ? "failure" : "warning",
- (values[ds_index] < min) ? min : max,
- ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
+ (values[ds_index] < min) ? min : max);
}
buf += status;
bufsize -= status;