From 0ccc0b1a9a548ab25844fc860cebcc69d0d31758 Mon Sep 17 00:00:00 2001 From: Scott Sanders Date: Mon, 8 Aug 2011 10:55:23 -0400 Subject: [PATCH] add config example and move host definitation out of attribute --- write_graphite.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/write_graphite.c b/write_graphite.c index b58dbfb0..420b7855 100644 --- a/write_graphite.c +++ b/write_graphite.c @@ -21,6 +21,17 @@ * based on the excellent write_http plugin **/ + /* write_graphite plugin configuation example + * + * + * + * Host "localhost" + * Port 2003 + * Prefix "collectd" + * + * + */ + #include "collectd.h" #include "common.h" #include "plugin.h" @@ -50,6 +61,8 @@ */ struct wg_callback { + char *name; + int sock_fd; struct hostent *server; @@ -608,21 +621,24 @@ static int wg_config_carbon (oconfig_item_t *ci) /* {{{ */ memset (cb, 0, sizeof (*cb)); cb->sock_fd = -1; cb->host = NULL; + cb->name = NULL; cb->port = 2003; cb->prefix = NULL; cb->server = NULL; pthread_mutex_init (&cb->send_lock, /* attr = */ NULL); - config_set_string (&cb->host, ci); - if (cb->host == NULL) + config_set_string (&cb->name, ci); + if (cb->name == NULL) return (-1); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; - if (strcasecmp ("Port", child->key) == 0) + if (strcasecmp ("Host", child->key) == 0) + config_set_string (&cb->host, child); + else if (strcasecmp ("Port", child->key) == 0) config_set_number (&cb->port, child); else if (strcasecmp ("Prefix", child->key) == 0) config_set_string (&cb->prefix, child); -- 2.11.0