X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectdctl.c;h=3bd8f0410f846ddf21130bf93ac8059555a7c269;hb=3b473acc5d4d27e5cf5101a4b8cc8a21c2bb7262;hp=adf45c97109f580a75187c71cb9281d4b0076e92;hpb=666394e4a4fe8efe6a98266b9dbac32e30064f45;p=collectd.git diff --git a/src/collectdctl.c b/src/collectdctl.c index adf45c97..3bd8f041 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -25,19 +25,47 @@ # include "config.h" #endif -#include "libcollectdclient/client.h" +#include +#include +#include +#include +#include #include - #include -#include - -#include -#include -#include +#if NAN_STATIC_DEFAULT +# include +/* #endif NAN_STATIC_DEFAULT*/ +#elif NAN_STATIC_ISOC +# ifndef __USE_ISOC99 +# define DISABLE_ISOC99 1 +# define __USE_ISOC99 1 +# endif /* !defined(__USE_ISOC99) */ +# include +# if DISABLE_ISOC99 +# undef DISABLE_ISOC99 +# undef __USE_ISOC99 +# endif /* DISABLE_ISOC99 */ +/* #endif NAN_STATIC_ISOC */ +#elif NAN_ZERO_ZERO +# include +# ifdef NAN +# undef NAN +# endif +# define NAN (0.0 / 0.0) +# ifndef isnan +# define isnan(f) ((f) != (f)) +# endif /* !defined(isnan) */ +# ifndef isfinite +# define isfinite(f) (((f) - (f)) == 0.0) +# endif +# ifndef isinf +# define isinf(f) (!isfinite(f) && !isnan(f)) +# endif +#endif /* NAN_ZERO_ZERO */ -#include +#include "libcollectdclient/client.h" #define DEFAULT_SOCK LOCALSTATEDIR"/run/"PACKAGE_NAME"-unixsock" @@ -239,7 +267,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 +280,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 +288,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 +299,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 +469,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 +497,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; }