{"latency", "latency", NULL},
/* Other stuff.. */
- {"corrupt-packets", "io_packets", "corrupt"},
+ {"corrupt-packets", "ipt_packets", "corrupt"},
{"deferred-cache-inserts", "counter", "cache-deferred_insert"},
{"deferred-cache-lookup", "counter", "cache-deferred_lookup"},
{"qsize-a", "cache_size", "answers"},
{"qsize-q", "cache_size", "questions"},
- {"servfail-packets", "io_packets", "servfail"},
- {"timedout-packets", "io_packets", "timeout"},
+ {"servfail-packets", "ipt_packets", "servfail"},
+ {"timedout-packets", "ipt_packets", "timeout"},
{"udp4-answers", "dns_answer", "udp4"},
{"udp4-queries", "dns_question", "queries-udp4"},
{"udp6-answers", "dns_answer", "udp6"},
return;
}
- if (ds->ds[0].type == DS_TYPE_GAUGE)
+ if (0 != parse_value (value, &values[0], ds->ds[0].type))
{
- char *endptr = NULL;
-
- values[0].gauge = strtod (value, &endptr);
-
- if (endptr == value)
- {
- ERROR ("powerdns plugin: Cannot convert `%s' "
- "to a floating point number.", value);
- return;
- }
- }
- else
- {
- char *endptr = NULL;
-
- values[0].counter = strtoll (value, &endptr, 0);
- if (endptr == value)
- {
- ERROR ("powerdns plugin: Cannot convert `%s' "
- "to an integer number.", value);
- return;
- }
+ ERROR ("powerdns plugin: Cannot convert `%s' "
+ "to a number.", value);
+ return;
}
vl.values = values;
vl.values_len = 1;
- vl.time = time (NULL);
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "powerdns", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* }}} static void submit */
static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */
memset (&sa_unix, 0, sizeof (sa_unix));
sa_unix.sun_family = AF_UNIX;
- strncpy (sa_unix.sun_path,
+ sstrncpy (sa_unix.sun_path,
(local_sockpath != NULL) ? local_sockpath : PDNS_LOCAL_SOCKPATH,
sizeof (sa_unix.sun_path));
- sa_unix.sun_path[sizeof (sa_unix.sun_path) - 1] = 0;
status = unlink (sa_unix.sun_path);
if ((status != 0) && (errno != ENOENT))
break;
}
+ struct timeval timeout;
+ timeout.tv_sec=2;
+ if (timeout.tv_sec < interval_g * 3 / 4)
+ timeout.tv_sec = interval_g * 3 / 4;
+ timeout.tv_usec=0;
+ status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout));
+ if (status != 0)
+ {
+ FUNC_ERROR ("setsockopt");
+ break;
+ }
+
status = connect (sd, (struct sockaddr *) &item->sockaddr,
sizeof (item->sockaddr));
if (status != 0)
}
item->sockaddr.sun_family = AF_UNIX;
- sstrncpy (item->sockaddr.sun_path, socket_temp, UNIX_PATH_MAX);
+ sstrncpy (item->sockaddr.sun_path, socket_temp,
+ sizeof (item->sockaddr.sun_path));
e = llentry_create (item->instance, item);
if (e == NULL)
powerdns_config_add_server (option);
else if (strcasecmp ("LocalSocket", option->key) == 0)
{
- char *temp = strdup (option->key);
- if (temp == NULL)
- return (1);
- sfree (local_sockpath);
- local_sockpath = temp;
+ if ((option->values_num != 1) || (option->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ WARNING ("powerdns plugin: `%s' needs exactly one string argument.", option->key);
+ }
+ else
+ {
+ char *temp = strdup (option->values[0].value.string);
+ if (temp == NULL)
+ return (1);
+ sfree (local_sockpath);
+ local_sockpath = temp;
+ }
}
else
{