X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fthreshold.c;h=391ee932aed1acf208bbd75c5fb56b243605ae0d;hb=a7850b871becb5121794a7fc6c1f7242588ee33f;hp=d4cfd6ea922ef2dbc984e6ca137f28774aa6ed68;hpb=45aa67ef031ed2b8083f92efa2cbb76e0da8c02e;p=collectd.git diff --git a/src/threshold.c b/src/threshold.c index d4cfd6ea..391ee932 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -361,7 +361,6 @@ static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci) for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; - status = 0; if (strcasecmp ("Instance", option->key) == 0) status = ut_config_type_instance (&th, option); @@ -449,7 +448,6 @@ static int ut_config_plugin (const threshold_t *th_orig, oconfig_item_t *ci) for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; - status = 0; if (strcasecmp ("Type", option->key) == 0) status = ut_config_type (&th, option); @@ -496,7 +494,6 @@ static int ut_config_host (const threshold_t *th_orig, oconfig_item_t *ci) for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; - status = 0; if (strcasecmp ("Type", option->key) == 0) status = ut_config_type (&th, option); @@ -625,13 +622,9 @@ static int ut_report_state (const data_set_t *ds, if (state == STATE_OKAY) { if (state_old == STATE_MISSING) - status = ssnprintf (buf, bufsize, - ": Value is no longer missing."); + ssnprintf (buf, bufsize, ": Value is no longer missing."); else - status = ssnprintf (buf, bufsize, - ": All data sources are within range again."); - buf += status; - bufsize -= status; + ssnprintf (buf, bufsize, ": All data sources are within range again."); } else { @@ -645,7 +638,7 @@ static int ut_report_state (const data_set_t *ds, { if (!isnan (min) && !isnan (max)) { - status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " + ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " "%f. That is within the %s region of %f%s and %f%s.", ds->ds[ds_index].name, values[ds_index], (state == STATE_ERROR) ? "failure" : "warning", @@ -654,13 +647,13 @@ static int ut_report_state (const data_set_t *ds, } else { - status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " - "%f. That is %s the %s threshold of %f%s.", - ds->ds[ds_index].name, values[ds_index], - isnan (min) ? "below" : "above", - (state == STATE_ERROR) ? "failure" : "warning", - isnan (min) ? max : min, - ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); + ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " + "%f. That is %s the %s threshold of %f%s.", + ds->ds[ds_index].name, values[ds_index], + isnan (min) ? "below" : "above", + (state == STATE_ERROR) ? "failure" : "warning", + isnan (min) ? max : min, + ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : ""); } } else if (th->flags & UT_FLAG_PERCENTAGE) @@ -683,7 +676,7 @@ static int ut_report_state (const data_set_t *ds, else value = 100.0 * values[ds_index] / sum; - status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " + 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", @@ -692,15 +685,13 @@ static int ut_report_state (const data_set_t *ds, } else /* is not inverted */ { - status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " - "%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); + ssnprintf (buf, bufsize, ": Data source \"%s\" is currently " + "%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); } - buf += status; - bufsize -= status; } plugin_dispatch_notification (&n); @@ -942,22 +933,25 @@ static int ut_missing (const value_list_t *vl, cdtime_t missing_time; char identifier[6 * DATA_MAX_NAME_LEN]; notification_t n; + cdtime_t now; - /* dispatch notifications for "interesting" values only */ if (threshold_tree == NULL) return (0); th = threshold_search (vl); - if (th == NULL) + /* dispatch notifications for "interesting" values only */ + if ((th == NULL) || ((th->flags & UT_FLAG_INTERESTING) == 0)) return (0); - missing_time = cdtime () - vl->time; + now = cdtime (); + missing_time = now - vl->time; FORMAT_VL (identifier, sizeof (identifier), vl); NOTIFICATION_INIT_VL (&n, vl); ssnprintf (n.message, sizeof (n.message), "%s has not been updated for %.3f seconds.", identifier, CDTIME_T_TO_DOUBLE (missing_time)); + n.time = now; plugin_dispatch_notification (&n); @@ -994,7 +988,6 @@ int ut_config (oconfig_item_t *ci) for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; - status = 0; if (strcasecmp ("Type", option->key) == 0) status = ut_config_type (&th, option);