#endif
#endif /* STRPTIME_NEEDS_STANDARDS */
+#if TIMEGM_NEEDS_BSD
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE 1
+#endif
+#endif /* TIMEGM_NEEDS_BSD */
+
#include "collectd.h"
#include "common.h"
#include "plugin.h"
+#include <time.h>
+
/* Some versions of libcurl don't include this themselves and then don't have
* fd_set available. */
#if HAVE_SYS_SELECT_H
{"ReqBadSIG", "dns_request", "BadSIG"},
{"ReqTCP", "dns_request", "TCP"},
/* Rejects */
- {"AuthQryRej", "dns_reject", "authorative"},
+ {"AuthQryRej", "dns_reject", "authoritative"},
{"RecQryRej", "dns_reject", "recursive"},
{"XfrRej", "dns_reject", "transfer"},
{"UpdateRej", "dns_reject", "update"},
{"RespTSIG", "dns_response", "TSIG"},
{"RespSIG0", "dns_response", "SIG0"},
/* Queries */
- {"QryAuthAns", "dns_query", "authorative"},
+ {"QryAuthAns", "dns_query", "authoritative"},
{"QryNoauthAns", "dns_query", "nonauth"},
{"QryReferral", "dns_query", "referral"},
{"QryRecursion", "dns_query", "recursion"},
- {"QryDuplicate", "dns_query", "dupliate"},
+ {"QryDuplicate", "dns_query", "duplicate"},
{"QryDropped", "dns_query", "dropped"},
{"QryFailure", "dns_query", "failure"},
/* Response codes */
{"QryFORMERR", "dns_rcode", "tx-FORMERR"},
{"QryNXDOMAIN", "dns_rcode", "tx-NXDOMAIN"}
#if 0
- { "XfrReqDone", "type", "type_instance" },
- { "UpdateReqFwd", "type", "type_instance" },
- { "UpdateRespFwd", "type", "type_instance" },
- { "UpdateFwdFail", "type", "type_instance" },
- { "UpdateDone", "type", "type_instance" },
- { "UpdateFail", "type", "type_instance" },
- { "UpdateBadPrereq", "type", "type_instance" },
+ { "XfrReqDone", "type", "type_instance" },
+ { "UpdateReqFwd", "type", "type_instance" },
+ { "UpdateRespFwd", "type", "type_instance" },
+ { "UpdateFwdFail", "type", "type_instance" },
+ { "UpdateDone", "type", "type_instance" },
+ { "UpdateFail", "type", "type_instance" },
+ { "UpdateBadPrereq", "type", "type_instance" },
#endif
};
static int nsstats_translation_table_length =
static void submit(time_t ts, const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, value_t value) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
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.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
return (-1);
}
- *ret_value = mktime(&tm);
+#if HAVE_TIMEGM
+ time_t t = timegm(&tm);
+ if (t == ((time_t)-1)) {
+ char errbuf[1024];
+ ERROR("bind plugin: timegm() failed: %s",
+ sstrerror(errno, errbuf, sizeof(errbuf)));
+ return (-1);
+ }
+ *ret_value = t;
+#else
+ time_t t = mktime(&tm);
+ if (t == ((time_t)-1)) {
+ char errbuf[1024];
+ ERROR("bind plugin: mktime() failed: %s",
+ sstrerror(errno, errbuf, sizeof(errbuf)));
+ return (-1);
+ }
+ /* mktime assumes that tm is local time. Luckily, it also sets timezone to
+ * the offset used for the conversion, and we undo the conversion to convert
+ * back to UTC. */
+ *ret_value = t - timezone;
+#endif
xmlXPathFreeObject(xpathObj);
return (0);
status = bind_xml_read_gauge(doc, counter, &value.gauge);
else
status = bind_xml_read_derive(doc, counter, &value.derive);
- if (status != 0)
+ if (status != 0) {
+ xmlFree(name);
continue;
+ }
status = (*list_callback)(name, value, current_time, user_data);
if (status == 0)
status = bind_xml_read_gauge(doc, child, &value.gauge);
else
status = bind_xml_read_derive(doc, child, &value.derive);
- if (status != 0)
+ if (status != 0) {
+ xmlFree(attr_name);
continue;
+ }
status = (*list_callback)(attr_name, value, current_time, user_data);
if (status == 0)
num_entries++;
+
+ xmlFree(attr_name);
}
}
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
curl_easy_setopt(curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
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_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
#ifdef HAVE_CURLOPT_TIMEOUT_MS
}
bind_buffer_fill = 0;
+
+ curl_easy_setopt(curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
+
if (curl_easy_perform(curl) != CURLE_OK) {
ERROR("bind plugin: curl_easy_perform failed: %s", bind_curl_error);
return (-1);