X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Faggregation.c;h=db33c177c039fa1676d9fcdc690b47d428f9a82b;hb=9de042657fa536305c5d98ef114dd9750ed4d656;hp=985fa7c35873c008b705be3aa45422c96d53fd99;hpb=d8e1728e5198087a77ecae83fcd8d63f6d4aad54;p=collectd.git diff --git a/src/aggregation.c b/src/aggregation.c index 985fa7c3..db33c177 100644 --- a/src/aggregation.c +++ b/src/aggregation.c @@ -192,13 +192,21 @@ static int agg_instance_update (agg_instance_t *inst, /* {{{ */ gauge_t *rate; if (ds->ds_num != 1) - return (-1); + { + ERROR ("aggregation plugin: The \"%s\" type (data set) has more than one " + "data source. This is currently not supported by this plugin. " + "Sorry.", ds->type); + return (EINVAL); + } rate = uc_get_rate (ds, vl); if (rate == NULL) { - ERROR ("aggregation plugin: uc_get_rate() failed."); - return (-1); + char ident[6 * DATA_MAX_NAME_LEN]; + FORMAT_VL (ident, sizeof (ident), vl); + ERROR ("aggregation plugin: Unable to read the current rate of \"%s\".", + ident); + return (ENOENT); } if (isnan (rate[0])) @@ -241,6 +249,12 @@ static int agg_instance_read_func (agg_instance_t *inst, /* {{{ */ status = rate_to_value (&v, rate, state, inst->ds_type, t); if (status != 0) { + /* If this is the first iteration and rate_to_value() was asked to return a + * COUNTER or a DERIVE, it will return EAGAIN. Catch this and handle + * gracefully. */ + if (status == EAGAIN) + return (0); + WARNING ("aggregation plugin: rate_to_value failed with status %i.", status); return (-1); @@ -606,6 +620,18 @@ static int agg_read (void) /* {{{ */ pthread_mutex_lock (&agg_instance_list_lock); + /* agg_instance_list_head only holds data, after the "write" callback has + * been called with a matching value list at least once. So on startup, + * there's a race between the aggregations read() and write() callback. If + * the read() callback is called first, agg_instance_list_head is NULL and + * "success" may be zero. This is expected and should not result in an error. + * Therefore we need to handle this case separately. */ + if (agg_instance_list_head == NULL) + { + pthread_mutex_unlock (&agg_instance_list_lock); + return (0); + } + for (this = agg_instance_list_head; this != NULL; this = this->next) { int status;