X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fvserver.c;h=6f9d46bfe12c33691342f04e7113615ea40d7087;hp=94da8609a8e7fa6ea4233603043837086f5d7bfe;hb=7111bb6df7628edce3a8e538b386fbe27633a191;hpb=79963d13c1884d1d92667cc502ad20758b084a12 diff --git a/src/vserver.c b/src/vserver.c index 94da8609..6f9d46bf 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -49,21 +49,19 @@ static int vserver_init(void) { * What's the right thing to do, if there is no getpagesize ()? */ pagesize = getpagesize(); - return (0); + return 0; } /* static void vserver_init(void) */ static void traffic_submit(const char *plugin_instance, const char *type_instance, 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}, + }; vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "vserver", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type, "if_octets", sizeof(vl.type)); @@ -74,16 +72,13 @@ static void traffic_submit(const char *plugin_instance, static void load_submit(const char *plugin_instance, gauge_t snum, gauge_t mnum, gauge_t lnum) { - value_t values[3]; value_list_t vl = VALUE_LIST_INIT; - - values[0].gauge = snum; - values[1].gauge = mnum; - values[2].gauge = lnum; + value_t values[] = { + {.gauge = snum}, {.gauge = mnum}, {.gauge = lnum}, + }; vl.values = values; vl.values_len = STATIC_ARRAY_SIZE(values); - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "vserver", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type, "load", sizeof(vl.type)); @@ -95,14 +90,10 @@ static void submit_gauge(const char *plugin_instance, const char *type, const char *type_instance, 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, "vserver", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type, type, sizeof(vl.type)); @@ -123,8 +114,8 @@ static derive_t vserver_get_sock_bytes(const char *s) { status = parse_value(s, &v, DS_TYPE_DERIVE); if (status != 0) - return (-1); - return (v.derive); + return -1; + return v.derive; } static int vserver_read(void) { @@ -136,7 +127,7 @@ static int vserver_read(void) { char errbuf[1024]; ERROR("vserver plugin: fopen (%s): %s", PROCDIR, sstrerror(errno, errbuf, sizeof(errbuf))); - return (-1); + return -1; } while (42) { @@ -163,13 +154,13 @@ static int vserver_read(void) { ERROR("vserver plugin: failed to read directory %s: %s", PROCDIR, sstrerror(errno, errbuf, sizeof(errbuf))); closedir(proc); - return (-1); + return -1; } if (dent->d_name[0] == '.') continue; - len = ssnprintf(file, sizeof(file), PROCDIR "/%s", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s", dent->d_name); if ((len < 0) || (len >= BUFSIZE)) continue; @@ -185,7 +176,7 @@ static int vserver_read(void) { continue; /* socket message accounting */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/cacct", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/cacct", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; @@ -229,7 +220,7 @@ static int vserver_read(void) { } /* thread information and load */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/cvirt", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/cvirt", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; @@ -275,7 +266,7 @@ static int vserver_read(void) { } /* processes and memory usage */ - len = ssnprintf(file, sizeof(file), PROCDIR "/%s/limit", dent->d_name); + len = snprintf(file, sizeof(file), PROCDIR "/%s/limit", dent->d_name); if ((len < 0) || ((size_t)len >= sizeof(file))) continue; @@ -323,12 +314,10 @@ static int vserver_read(void) { closedir(proc); - return (0); + return 0; } /* int vserver_read */ void module_register(void) { plugin_register_init("vserver", vserver_init); plugin_register_read("vserver", vserver_read); } /* void module_register(void) */ - -/* vim: set ts=4 sw=4 noexpandtab : */