X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectdctl.c;h=f16a70dd94285861bc5d8bac19debfc66a4f74f0;hb=da69316b56551acab689af78809ec88d48a601cd;hp=adf45c97109f580a75187c71cb9281d4b0076e92;hpb=666394e4a4fe8efe6a98266b9dbac32e30064f45;p=collectd.git diff --git a/src/collectdctl.c b/src/collectdctl.c index adf45c97..f16a70dd 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -25,19 +25,30 @@ # include "config.h" #endif -#include "libcollectdclient/client.h" - -#include +#ifndef _ISOC99_SOURCE +# define _ISOC99_SOURCE +#endif -#include +#ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200112L +#endif -#include +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +#endif -#include #include +#include +#include #include +#include + +#include +#include +#include + +#include "libcollectdclient/collectd/client.h" -#include #define DEFAULT_SOCK LOCALSTATEDIR"/run/"PACKAGE_NAME"-unixsock" @@ -239,7 +250,7 @@ static int flush (lcc_connection_t *c, int argc, char **argv) if (strcasecmp (key, "timeout") == 0) { char *endptr = NULL; - timeout = strtol (value, &endptr, 0); + timeout = (int) strtol (value, &endptr, 0); if (endptr == value) { fprintf (stderr, "ERROR: Failed to parse timeout as number: %s.\n", @@ -252,7 +263,7 @@ static int flush (lcc_connection_t *c, int argc, char **argv) } } else if (strcasecmp (key, "plugin") == 0) { - status = array_grow ((void **)&plugins, &plugins_num, + status = array_grow ((void *)&plugins, &plugins_num, sizeof (*plugins)); if (status != 0) BAIL_OUT (status); @@ -260,7 +271,7 @@ static int flush (lcc_connection_t *c, int argc, char **argv) plugins[plugins_num - 1] = value; } else if (strcasecmp (key, "identifier") == 0) { - status = array_grow ((void **)&identifiers, &identifiers_num, + status = array_grow ((void *)&identifiers, &identifiers_num, sizeof (*identifiers)); if (status != 0) BAIL_OUT (status); @@ -271,10 +282,14 @@ static int flush (lcc_connection_t *c, int argc, char **argv) if (status != 0) BAIL_OUT (status); } + else { + fprintf (stderr, "ERROR: flush: Unknown option `%s'.\n", key); + BAIL_OUT (-1); + } } if (plugins_num == 0) { - status = array_grow ((void **)&plugins, &plugins_num, sizeof (*plugins)); + status = array_grow ((void *)&plugins, &plugins_num, sizeof (*plugins)); if (status != 0) BAIL_OUT (status); @@ -437,7 +452,7 @@ static int putval (lcc_connection_t *c, int argc, char **argv) vl.time = strtol (argv[i], &endptr, 0); - if (endptr == value) { + if (endptr == argv[i]) { fprintf (stderr, "ERROR: Failed to parse time as number: %s.\n", argv[i]); return (-1); @@ -465,7 +480,12 @@ static int putval (lcc_connection_t *c, int argc, char **argv) * anyway. Also, lcc uses the type information for formatting the * number only, so the real meaning does not matter. -tokkee */ dot = strchr (value, (int)'.'); - if (dot) { /* floating point value */ + endptr = NULL; + if (strcasecmp (value, "U") == 0) { + values[values_len].gauge = NAN; + values_types[values_len] = LCC_TYPE_GAUGE; + } + else if (dot) { /* floating point value */ values[values_len].gauge = strtod (value, &endptr); values_types[values_len] = LCC_TYPE_GAUGE; }