X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpowerdns.c;h=7b7cab39ddd62580b9e45fe28caf92b871b2822e;hb=88f22ff8b4c69eb38b6aaab30df212df1871d4ec;hp=151e09c9fb31f8fdb608d116e430725b492c0362;hpb=de64a9127f1a6da9052f5d4d55eeadce9d574c85;p=collectd.git diff --git a/src/powerdns.c b/src/powerdns.c index 151e09c9..7b7cab39 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 @@ -298,7 +298,7 @@ static void submit (const char *plugin_instance, /* {{{ */ if (ds->ds_num != 1) { - ERROR ("powerdns plugin: type `%s' has %i data sources, " + ERROR ("powerdns plugin: type `%s' has %zu data sources, " "but I can only handle one.", type, ds->ds_num); return; @@ -462,6 +462,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)); @@ -509,7 +515,6 @@ static int powerdns_get_data_stream (list_item_t *item, /* {{{ */ buffer[buffer_size] = 0; } /* while (42) */ close (sd); - sd = -1; if (status < 0) { @@ -645,12 +650,12 @@ static int powerdns_update_recursor_command (list_item_t *li) /* {{{ */ return (-1); } buffer[sizeof (buffer) - 1] = 0; - int i = strlen (buffer); - if (i < sizeof (buffer) - 2) + size_t len = strlen (buffer); + if (len < sizeof (buffer) - 2) { - buffer[i++] = ' '; - buffer[i++] = '\n'; - buffer[i++] = '\0'; + buffer[len++] = ' '; + buffer[len++] = '\n'; + buffer[len++] = '\0'; } } @@ -732,25 +737,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) { @@ -861,7 +847,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); @@ -901,12 +887,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 */