X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ffscache.c;h=33633d63247db02deb1c7a909d228557b90184c2;hb=db961f476426f5dd3ca1663ffc094f0fc7f6f8a2;hp=dc0eb1194dcc95fdaa8292706fb3fb26bdb09638;hpb=658e44d47088aaea3c59fb248336a74fdefe4245;p=collectd.git diff --git a/src/fscache.c b/src/fscache.c index dc0eb119..33633d63 100644 --- a/src/fscache.c +++ b/src/fscache.c @@ -20,6 +20,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include /* a header needed for FILE */ @@ -107,16 +108,13 @@ Ops pend=N Number of times async ops added to pending queues 63 events to collect in 13 groups */ static void fscache_submit (const char *section, const char *name, - counter_t counter_value) + value_t value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - vl.values = values; + vl.values = &value; vl.values_len = 1; - vl.values[0].counter = counter_value; - sstrncpy(vl.host, hostname_g, sizeof (vl.host)); sstrncpy(vl.plugin, "fscache", sizeof (vl.plugin)); sstrncpy(vl.plugin_instance, section, sizeof (vl.plugin_instance)); @@ -161,7 +159,6 @@ static void fscache_read_stats_file (FILE *fh) char *lineptr; char *fields[32]; int fields_num; - int i; /* Find the colon and replace it with a null byte */ lineptr = strchr (linebuffer, ':'); @@ -178,19 +175,19 @@ static void fscache_read_stats_file (FILE *fh) section_len--; section[section_len] = 0; } - if (section_len <= 0) + if (section_len == 0) continue; fields_num = strsplit (lineptr, fields, STATIC_ARRAY_SIZE (fields)); if (fields_num <= 0) continue; - for (i = 0; i < fields_num; i++) + for (int i = 0; i < fields_num; i++) { char *field_name; char *field_value_str; - char *endptr; - counter_t field_value_cnt; + value_t field_value_cnt; + int status; field_name = fields[i]; assert (field_name != NULL); @@ -201,11 +198,9 @@ static void fscache_read_stats_file (FILE *fh) *field_value_str = 0; field_value_str++; - errno = 0; - endptr = NULL; - field_value_cnt = (counter_t) strtoull (field_value_str, - &endptr, /* base = */ 10); - if ((errno != 0) || (endptr == field_value_str)) + status = parse_value (field_value_str, &field_value_cnt, + DS_TYPE_DERIVE); + if (status != 0) continue; fscache_submit (section, field_name, field_value_cnt);