X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fxencpu.c;h=de375d2682a1eb0e281b4d5a711a0f6073139d0b;hb=0a8741b9061f8df4a78a448c021612db06e17425;hp=ab053965a85ae670ab3a902b0b5d3e19c2ce3314;hpb=cd5c60931ef73c6c34be6dcf58538b069be17c58;p=collectd.git diff --git a/src/xencpu.c b/src/xencpu.c index ab053965..de375d26 100644 --- a/src/xencpu.c +++ b/src/xencpu.c @@ -20,6 +20,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -107,17 +108,13 @@ static int xencpu_shutdown (void) return 0; } /* static int xencpu_shutdown */ -static void submit_value (int cpu_num, gauge_t percent) +static void submit_value (int cpu_num, gauge_t value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = percent; - - vl.values = values; + vl.values = &(value_t) { .gauge = value }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "xencpu", sizeof (vl.plugin)); sstrncpy (vl.type, "percent", sizeof (vl.type)); sstrncpy (vl.type_instance, "load", sizeof (vl.type_instance)); @@ -141,12 +138,13 @@ static int xencpu_read (void) return (-1); } - int cpu, status; - for (cpu = 0; cpu < nr_cpus; cpu++) { + int status; + for (int cpu = 0; cpu < nr_cpus; cpu++) { gauge_t rate = NAN; - value_t value = {.derive = cpu_info[cpu].idletime}; - status = value_to_rate (&rate, value, DS_TYPE_DERIVE, now, &cpu_states[cpu]); + status = value_to_rate (&rate, + (value_t) { .derive = cpu_info[cpu].idletime }, DS_TYPE_DERIVE, + now, &cpu_states[cpu]); if (status == 0) { submit_value(cpu, 100 - rate/10000000); }