- * 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
-/* Set to C99 and POSIX code */
-#ifndef _ISOC99_SOURCE
-# define _ISOC99_SOURCE
-#endif
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
-#ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
-#endif
-#ifndef _REENTRANT
-# define _REENTRANT
-#endif
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 600
-#endif
-#ifndef _BSD_SOURCE
-# define _BSD_SOURCE
-#endif
+#include "config.h"
+
+#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 */
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) {
- 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);
list_callback_t list_callback,
void *user_data,
xmlDoc *doc, xmlXPathContext *xpathCtx,
list_callback_t list_callback,
void *user_data,
xmlDoc *doc, xmlXPathContext *xpathCtx,
- status = bind_xml_read_counter (doc, counter, &value.counter);
+ if (ds_type == DS_TYPE_GAUGE)
+ status = bind_xml_read_gauge (doc, counter, &value.gauge);
+ else
+ status = bind_xml_read_derive (doc, counter, &value.derive);
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
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-qtypes",
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-qtypes",
bind_parse_generic_name_value (/* xpath = */ "rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value ("resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-cache_rr_sets",
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-cache_rr_sets",
bind_parse_generic_name_value (/* xpath = */ "cache/rrset",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "cache/rrset",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "server/requests/opcode",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "server/requests/opcode",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "server/queries-in/rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value (/* xpath = */ "server/queries-in/rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
bind_parse_generic_name_value ("server/nsstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("server/nsstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("server/zonestat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("server/zonestat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("server/resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
bind_parse_generic_name_value ("server/resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION);
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, bind_curl_error);
curl_easy_setopt (curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);