#include "collectd.h"
-#include "common.h"
#include "plugin.h"
-#include "utils_avltree.h"
+#include "utils/avltree/avltree.h"
+#include "utils/common/common.h"
#if HAVE_NETDB_H
#include <netdb.h>
sockets_num++;
break;
} else {
- int yes = 1;
-
status = setsockopt(sockets[sockets_num].fd, SOL_SOCKET, SO_REUSEADDR,
- (void *)&yes, sizeof(yes));
+ &(int){1}, sizeof(int));
if (status != 0) {
WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
sstrncpy(se->key, key, sizeof(se->key));
se->flags = 0;
- se->vl.values = (value_t *)calloc(values_len, sizeof(*se->vl.values));
+ se->vl.values = calloc(values_len, sizeof(*se->vl.values));
if (se->vl.values == NULL) {
sfree(se);
return NULL;
return (void *)-1;
}
- mc_receive_sockets = (struct pollfd *)calloc(mc_receive_sockets_num,
- sizeof(*mc_receive_sockets));
+ mc_receive_sockets =
+ calloc(mc_receive_sockets_num, sizeof(*mc_receive_sockets));
if (mc_receive_sockets == NULL) {
ERROR("gmond plugin: calloc failed.");
for (size_t i = 0; i < mc_receive_sockets_num; i++)
* </Metric>
* </Plugin>
*/
-static int gmond_config_set_string(oconfig_item_t *ci, char **str) /* {{{ */
-{
- char *tmp;
-
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
- WARNING("gmond plugin: The `%s' option needs "
- "exactly one string argument.",
- ci->key);
- return -1;
- }
-
- tmp = strdup(ci->values[0].value.string);
- if (tmp == NULL) {
- ERROR("gmond plugin: strdup failed.");
- return -1;
- }
-
- sfree(*str);
- *str = tmp;
- return 0;
-} /* }}} int gmond_config_set_string */
-
static int gmond_config_add_metric(oconfig_item_t *ci) /* {{{ */
{
metric_map_t *map;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Type", child->key) == 0)
- gmond_config_set_string(child, &map->type);
+ cf_util_get_string(child, &map->type);
else if (strcasecmp("TypeInstance", child->key) == 0)
- gmond_config_set_string(child, &map->type_instance);
+ cf_util_get_string(child, &map->type_instance);
else if (strcasecmp("DataSource", child->key) == 0)
- gmond_config_set_string(child, &map->ds_name);
+ cf_util_get_string(child, &map->ds_name);
else {
WARNING("gmond plugin: Unknown configuration option `%s' ignored.",
child->key);