X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fturbostat.c;h=31321490309d7a63c0fb449e0944e3b1b835042c;hb=ec43e8a33bdcb116e75310c7bd9daae3bc912834;hp=2d8a08e646319b961f8ffb24f1a8654bb470c23f;hpb=08cf386cb8aa711ef4043d9139d464b38188a44b;p=collectd.git diff --git a/src/turbostat.c b/src/turbostat.c index 2d8a08e6..31321490 100644 --- a/src/turbostat.c +++ b/src/turbostat.c @@ -524,12 +524,9 @@ turbostat_submit (const char *plugin_instance, gauge_t value) { value_list_t vl = VALUE_LIST_INIT; - value_t v; - v.gauge = value; - vl.values = &v; + vl.values = &(value_t) { .gauge = value }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, PLUGIN_NAME, sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); @@ -1018,8 +1015,7 @@ parse_int_file(const char *fmt, ...) { va_list args; char path[PATH_MAX]; - FILE *filep; - int len, value; + int len; va_start(args, fmt); len = vsnprintf(path, sizeof(path), fmt, args); @@ -1029,18 +1025,13 @@ parse_int_file(const char *fmt, ...) return -1; } - filep = fopen(path, "r"); - if (!filep) { - ERROR("turbostat plugin: Failed to open '%s'", path); - return -1; - } - if (fscanf(filep, "%d", &value) != 1) { - ERROR("turbostat plugin: Failed to parse number from '%s'", path); - fclose(filep); + value_t v; + if (parse_value_file (path, &v, DS_TYPE_DERIVE) != 0) { + ERROR ("turbostat plugin: Parsing \"%s\" failed.", path); return -1; } - fclose(filep); - return value; + + return (int) v.derive; } static int