X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fthreshold.c;h=ed8312992b437c9984d6885309bc972f1450fb4d;hb=e12d678adf06fb477f54afd3d7e13c73a94719dc;hp=8dcb711d5e6004bb82d266b8d9e950242681c50d;hpb=d8a02e6c6f5875dfcab7b011d1f340e3a13c9e39;p=collectd.git diff --git a/src/threshold.c b/src/threshold.c index 8dcb711d..ed831299 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -553,7 +553,7 @@ static int ut_report_state (const data_set_t *ds, { gauge_t value; gauge_t sum; - int i; + size_t i; sum = 0.0; for (i = 0; i < vl->values_len; i++) @@ -701,7 +701,7 @@ static int ut_check_one_threshold (const data_set_t *ds, { /* {{{ */ int ret = -1; int ds_index = -1; - int i; + size_t i; gauge_t values_copy[ds->ds_num]; memcpy (values_copy, values, sizeof (values_copy)); @@ -868,10 +868,11 @@ static int ut_missing (const value_list_t *vl, return (0); } /* }}} int ut_missing */ -int ut_config (oconfig_item_t *ci) +static int ut_config (oconfig_item_t *ci) { /* {{{ */ int i; int status = 0; + int old_size = c_avl_size (threshold_tree); threshold_t th; @@ -915,7 +916,9 @@ int ut_config (oconfig_item_t *ci) break; } - if (c_avl_size (threshold_tree) > 0) { + /* register callbacks if this is the first time we see a valid config */ + if ((old_size == 0) && (c_avl_size (threshold_tree) > 0)) + { plugin_register_missing ("threshold", ut_missing, /* user data = */ NULL); plugin_register_write ("threshold", ut_check_threshold,