X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_tail_match.c;h=22c7917943524ed3c3ee06415cc3159b3ab61892;hb=be99a844a40d7037a910d37a894988b807631a6e;hp=b71e205932a57e1ff57c08feb259eb3c83cd09b7;hpb=41c75b9df38ae4d91438693564580eaf796578b0;p=collectd.git diff --git a/src/utils_tail_match.c b/src/utils_tail_match.c index b71e2059..22c79179 100644 --- a/src/utils_tail_match.c +++ b/src/utils_tail_match.c @@ -72,27 +72,38 @@ static int simple_submit_match (cu_match_t *match, void *user_data) if (match_value == NULL) return (-1); - values[0] = match_value->value; + if ((match_value->ds_type & UTILS_MATCH_DS_TYPE_GAUGE) + && (match_value->values_num == 0)) + values[0].gauge = NAN; + else + values[0] = match_value->value; vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, data->plugin, sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, data->plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, data->type, sizeof (vl.type)); sstrncpy (vl.type_instance, data->type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (data->type, &vl); + plugin_dispatch_values (&vl); + + if (match_value->ds_type & UTILS_MATCH_DS_TYPE_GAUGE) + { + match_value->value.gauge = NAN; + match_value->values_num = 0; + } return (0); } /* int simple_submit_match */ -static int tail_callback (void *data, char *buf, int buflen) +static int tail_callback (void *data, char *buf, + int __attribute__((unused)) buflen) { cu_tail_match_t *obj = (cu_tail_match_t *) data; - int i; + size_t i; for (i = 0; i < obj->matches_num; i++) match_apply (obj->matches[i].match, buf); @@ -124,7 +135,7 @@ cu_tail_match_t *tail_match_create (const char *filename) void tail_match_destroy (cu_tail_match_t *obj) { - int i; + size_t i; if (obj == NULL) return; @@ -226,7 +237,7 @@ int tail_match_read (cu_tail_match_t *obj) { char buffer[4096]; int status; - int i; + size_t i; status = cu_tail_read (obj->tail, buffer, sizeof (buffer), tail_callback, (void *) obj);