X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fopenvpn.c;h=90694b786fc9b96fa6798a5febdc98322109d7f0;hb=877672d20fcf0ed25f5fc5faa8aa3964c622bc27;hp=11c119c854399b368f04882d52efa1346b9e98c1;hpb=79963d13c1884d1d92667cc502ad20758b084a12;p=collectd.git diff --git a/src/openvpn.c b/src/openvpn.c index 11c119c8..90694b78 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -94,14 +94,10 @@ static int openvpn_strsplit(char *string, char **fields, size_t size) { /* dispatches number of users */ static void numusers_submit(const char *pinst, const char *tinst, gauge_t value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = value; - - vl.values = values; - vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); + vl.values = &(value_t){.gauge = value}; + vl.values_len = 1; sstrncpy(vl.plugin, "openvpn", sizeof(vl.plugin)); sstrncpy(vl.type, "users", sizeof(vl.type)); if (pinst != NULL) @@ -116,11 +112,10 @@ static void numusers_submit(const char *pinst, const char *tinst, * per single endpoint */ static void iostats_submit(const char *pinst, const char *tinst, derive_t rx, derive_t tx) { - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - - values[0].derive = rx; - values[1].derive = tx; + value_t values[] = { + {.derive = rx}, {.derive = tx}, + }; /* NOTE ON THE NEW NAMING SCHEMA: * using plugin_instance to identify each vpn config (and @@ -130,7 +125,6 @@ static void iostats_submit(const char *pinst, const char *tinst, derive_t rx, vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "openvpn", sizeof(vl.plugin)); if (pinst != NULL) sstrncpy(vl.plugin_instance, pinst, sizeof(vl.plugin_instance)); @@ -144,15 +138,13 @@ static void iostats_submit(const char *pinst, const char *tinst, derive_t rx, /* dispatches stats about data compression shown when in single mode */ static void compression_submit(const char *pinst, const char *tinst, derive_t uncompressed, derive_t compressed) { - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - - values[0].derive = uncompressed; - values[1].derive = compressed; + value_t values[] = { + {.derive = uncompressed}, {.derive = compressed}, + }; vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "openvpn", sizeof(vl.plugin)); if (pinst != NULL) sstrncpy(vl.plugin_instance, pinst, sizeof(vl.plugin_instance));