X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpowerdns.c;h=673c0d651c3a9ef4b664d87855666c9d1b60cb26;hb=f8379dd45f4a43595f4027992696ee8d02908bff;hp=a1b23555bec080592a261f91e1d6e02ae769bd6a;hpb=3904b4b9fd1a53c93f31d8fec709a7b7b8300513;p=collectd.git diff --git a/src/powerdns.c b/src/powerdns.c index a1b23555..673c0d65 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 @@ -123,7 +123,7 @@ user-msec number of CPU milliseconds spent in 'user' mode const char* const default_server_fields[] = /* {{{ */ { - "latency" + "latency", "packetcache-hit", "packetcache-miss", "packetcache-size", @@ -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; @@ -364,7 +364,7 @@ static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */ break; } - cdt_timeout = interval_g * 3 / 4; + cdt_timeout = plugin_get_interval () * 3 / 4; if (cdt_timeout < TIME_T_TO_CDTIME_T (2)) cdt_timeout = TIME_T_TO_CDTIME_T (2); @@ -447,6 +447,12 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */ timeout.tv_sec=5; timeout.tv_usec=0; status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout)); + if (status != 0) + { + FUNC_ERROR ("setsockopt"); + close (sd); + return (-1); + } status = connect (sd, (struct sockaddr *) &item->sockaddr, sizeof (item->sockaddr)); @@ -494,7 +500,6 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */ buffer[buffer_size] = 0; } /* while (42) */ close (sd); - sd = -1; if (status < 0) { @@ -717,25 +722,6 @@ static int powerdns_read_recursor (list_item_t *item) /* {{{ */ return (0); } /* }}} int powerdns_read_recursor */ -static int powerdns_config_add_string (const char *name, /* {{{ */ - char **dest, - oconfig_item_t *ci) -{ - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) - { - WARNING ("powerdns plugin: `%s' needs exactly one string argument.", - name); - return (-1); - } - - sfree (*dest); - *dest = strdup (ci->values[0].value.string); - if (*dest == NULL) - return (-1); - - return (0); -} /* }}} int powerdns_config_add_string */ - static int powerdns_config_add_collect (list_item_t *li, /* {{{ */ oconfig_item_t *ci) { @@ -846,7 +832,7 @@ static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */ if (strcasecmp ("Collect", option->key) == 0) status = powerdns_config_add_collect (item, option); else if (strcasecmp ("Socket", option->key) == 0) - status = powerdns_config_add_string ("Socket", &socket_temp, option); + status = cf_util_get_string (option, &socket_temp); else { ERROR ("powerdns plugin: Option `%s' not allowed here.", option->key); @@ -886,12 +872,14 @@ static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */ if (status != 0) { + sfree (socket_temp); sfree (item); return (-1); } DEBUG ("powerdns plugin: Add server: instance = %s;", item->instance); + sfree (socket_temp); return (0); } /* }}} int powerdns_config_add_server */