diff --git a/src/bind.c b/src/bind.c
index 32e9d04bc266cf887165ee4fba35801c9d026453..ddde840a4813df60c4b49c1bc168a80689037c3f 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
/**
* collectd - src/bind.c
/**
* collectd - src/bind.c
- * Copyright (C) 2009 Bruno Prémont
- * Copyright (C) 2009 Florian Forster
+ * Copyright (C) 2009 Bruno Prémont
+ * Copyright (C) 2009,2010 Florian Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* Authors:
* Bruno Prémont <bonbons at linux-vserver.org>
*
* Authors:
* Bruno Prémont <bonbons at linux-vserver.org>
- * Florian Forster <octo at verplant.org>
+ * Florian Forster <octo at collectd.org>
**/
#include "config.h"
**/
#include "config.h"
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 600 /* glibc2 needs this for strptime */
-#endif
+#if STRPTIME_NEEDS_STANDARDS
+# ifndef _ISOC99_SOURCE
+# define _ISOC99_SOURCE 1
+# endif
+# ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+# endif
+# ifndef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 500
+# endif
+#endif /* STRPTIME_NEEDS_STANDARDS */
#include "collectd.h"
#include "common.h"
#include "collectd.h"
#include "common.h"
};
typedef struct list_info_ptr_s list_info_ptr_t;
};
typedef struct list_info_ptr_s list_info_ptr_t;
+/* FIXME: Enabled by default for backwards compatibility. */
+/* TODO: Remove time parsing code. */
+static _Bool config_parse_time = 1;
+
static char *url = NULL;
static int global_opcodes = 1;
static int global_qtypes = 1;
static char *url = NULL;
static int global_opcodes = 1;
static int global_qtypes = 1;
vl.values = values;
vl.values_len = 1;
vl.values = values;
vl.values_len = 1;
- vl.time = ts;
+ if (config_parse_time)
+ vl.time = TIME_T_TO_CDTIME_T (ts);
sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "bind", sizeof(vl.plugin));
if (plugin_instance) {
sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "bind", sizeof(vl.plugin));
if (plugin_instance) {
return (0);
} /* }}} int bind_xml_list_callback */
return (0);
} /* }}} int bind_xml_list_callback */
-static int bind_xml_read_counter (xmlDoc *doc, xmlNode *node, /* {{{ */
- counter_t *ret_value)
+static int bind_xml_read_derive (xmlDoc *doc, xmlNode *node, /* {{{ */
+ derive_t *ret_value)
{
{
- char *str_ptr, *end_ptr;
- long long int value;
+ char *str_ptr;
+ value_t value;
+ int status;
str_ptr = (char *) xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
if (str_ptr == NULL)
{
str_ptr = (char *) xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
if (str_ptr == NULL)
{
- ERROR ("bind plugin: bind_xml_read_counter: xmlNodeListGetString failed.");
+ ERROR ("bind plugin: bind_xml_read_derive: xmlNodeListGetString failed.");
return (-1);
}
return (-1);
}
- errno = 0;
- value = strtoll (str_ptr, &end_ptr, 10);
- xmlFree(str_ptr);
- if (str_ptr == end_ptr || errno)
+ status = parse_value (str_ptr, &value, DS_TYPE_DERIVE);
+ if (status != 0)
{
{
- if (errno && (value < 0))
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with underflow.");
- else if (errno && (value > 0))
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed with overflow.");
- else
- ERROR ("bind plugin: bind_xml_read_counter: strtoll failed.");
+ ERROR ("bind plugin: Parsing string \"%s\" to derive value failed.",
+ str_ptr);
return (-1);
}
return (-1);
}
- *ret_value = value;
+ *ret_value = value.derive;
return (0);
return (0);
-} /* }}} int bind_xml_read_counter */
+} /* }}} int bind_xml_read_derive */
static int bind_xml_read_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */
gauge_t *ret_value)
static int bind_xml_read_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */
gauge_t *ret_value)
@@ -527,7 +535,7 @@ static int bind_parse_generic_name_value (const char *xpath_expression, /* {{{ *
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, counter, &value.gauge);
else
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, counter, &value.gauge);
else
- status = bind_xml_read_counter (doc, counter, &value.counter);
+ status = bind_xml_read_derive (doc, counter, &value.derive);
if (status != 0)
continue;
if (status != 0)
continue;
@@ -600,7 +608,7 @@ static int bind_parse_generic_value_list (const char *xpath_expression, /* {{{ *
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, child, &value.gauge);
else
if (ds_type == DS_TYPE_GAUGE)
status = bind_xml_read_gauge (doc, child, &value.gauge);
else
- status = bind_xml_read_counter (doc, child, &value.counter);
+ status = bind_xml_read_derive (doc, child, &value.derive);
if (status != 0)
continue;
if (status != 0)
continue;
bind_config_set_bool ("MemoryStats", &global_memory_stats, child);
else if (strcasecmp ("View", child->key) == 0)
bind_config_add_view (child);
bind_config_set_bool ("MemoryStats", &global_memory_stats, child);
else if (strcasecmp ("View", child->key) == 0)
bind_config_add_view (child);
+ else if (strcasecmp ("ParseTime", child->key) == 0)
+ cf_util_get_boolean (child, &config_parse_time);
else
{
WARNING ("bind plugin: Unknown configuration option "
else
{
WARNING ("bind plugin: Unknown configuration option "
}
bind_buffer_fill = 0;
}
bind_buffer_fill = 0;
- if (curl_easy_perform (curl) != 0)
+ if (curl_easy_perform (curl) != CURLE_OK)
{
ERROR ("bind plugin: curl_easy_perform failed: %s",
bind_curl_error);
{
ERROR ("bind plugin: curl_easy_perform failed: %s",
bind_curl_error);