X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpowerdns.c;h=81e253bf44f34c778fc55752c06904acde649b7b;hb=aee87d9c1665ca8823c7489bfc9900ff12e0e177;hp=29f6bca502c7b48be0ecbadd2bc4befabf337885;hpb=7a0db7f902f3224ff76c3a21d7b218575d72ba1b;p=collectd.git diff --git a/src/powerdns.c b/src/powerdns.c index 29f6bca5..81e253bf 100644 --- a/src/powerdns.c +++ b/src/powerdns.c @@ -84,10 +84,10 @@ typedef struct statname_lookup_s statname_lookup_t; /* Description of statistics returned by the recursor: {{{ all-outqueries counts the number of outgoing UDP queries since starting -answers0-1 counts the number of queries answered within 1 milisecond +answers0-1 counts the number of queries answered within 1 millisecond answers100-1000 counts the number of queries answered within 1 second -answers10-100 counts the number of queries answered within 100 miliseconds -answers1-10 counts the number of queries answered within 10 miliseconds +answers10-100 counts the number of queries answered within 100 milliseconds +answers1-10 counts the number of queries answered within 10 milliseconds answers-slow counts the number of queries answered after 1 second cache-entries shows the number of entries in the cache cache-hits counts the number of cache hits since starting @@ -259,9 +259,6 @@ static void submit (const char *plugin_instance, /* {{{ */ if (strcmp (lookup_table[i].name, pdns_type) == 0) break; - if (lookup_table[i].type == NULL) - return; - if (i >= lookup_table_length) { INFO ("powerdns plugin: submit: Not found in lookup table: %s = %s;", @@ -269,6 +266,9 @@ static void submit (const char *plugin_instance, /* {{{ */ return; } + if (lookup_table[i].type == NULL) + return; + type = lookup_table[i].type; type_instance = lookup_table[i].type_instance; @@ -321,6 +321,9 @@ static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */ struct sockaddr_un sa_unix; + struct timeval stv_timeout; + cdtime_t cdt_timeout; + sd = socket (PF_UNIX, item->socktype, 0); if (sd < 0) { @@ -361,12 +364,13 @@ static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */ 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)); + cdt_timeout = plugin_get_interval () * 3 / 4; + if (cdt_timeout < TIME_T_TO_CDTIME_T (2)) + cdt_timeout = TIME_T_TO_CDTIME_T (2); + + CDTIME_T_TO_TIMEVAL (cdt_timeout, &stv_timeout); + + status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &stv_timeout, sizeof (stv_timeout)); if (status != 0) { FUNC_ERROR ("setsockopt");