Code

Merge remote-tracking branch 'github/pr/387'
[collectd.git] / src / write_riemann.c
1 /**
2  * collectd - src/write_riemann.c
3  *
4  * Copyright (C) 2012,2013  Pierre-Yves Ritschard
5  * Copyright (C) 2013       Florian octo Forster
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
16  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
17  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  *
19  * Authors:
20  *   Pierre-Yves Ritschard <pyr at spootnik.org>
21  *   Florian octo Forster <octo at collectd.org>
22  */
24 #include "collectd.h"
25 #include "plugin.h"
26 #include "common.h"
27 #include "configfile.h"
28 #include "utils_cache.h"
29 #include "riemann.pb-c.h"
31 #include <sys/socket.h>
32 #include <arpa/inet.h>
33 #include <errno.h>
34 #include <netdb.h>
35 #include <inttypes.h>
36 #include <pthread.h>
38 #define RIEMANN_HOST            "localhost"
39 #define RIEMANN_PORT            "5555"
40 #define RIEMANN_TTL_FACTOR      2.0
42 struct riemann_host {
43         char                    *name;
44 #define F_CONNECT                0x01
45         uint8_t                  flags;
46         pthread_mutex_t          lock;
47         _Bool                    store_rates;
48         _Bool                    always_append_ds;
49         char                    *node;
50         char                    *service;
51         _Bool                    use_tcp;
52         int                      s;
53         double                   ttl_factor;
55         int                      reference_count;
56 };
58 static char     **riemann_tags;
59 static size_t     riemann_tags_num;
61 static void riemann_event_protobuf_free (Event *event) /* {{{ */
62 {
63         size_t i;
65         if (event == NULL)
66                 return;
68         sfree (event->state);
69         sfree (event->service);
70         sfree (event->host);
71         sfree (event->description);
73         strarray_free (event->tags, event->n_tags);
74         event->tags = NULL;
75         event->n_tags = 0;
77         for (i = 0; i < event->n_attributes; i++)
78         {
79                 sfree (event->attributes[i]->key);
80                 sfree (event->attributes[i]->value);
81                 sfree (event->attributes[i]);
82         }
83         sfree (event->attributes);
84         event->n_attributes = 0;
86         sfree (event);
87 } /* }}} void riemann_event_protobuf_free */
89 static void riemann_msg_protobuf_free (Msg *msg) /* {{{ */
90 {
91         size_t i;
93         if (msg == NULL)
94                 return;
96         for (i = 0; i < msg->n_events; i++)
97         {
98                 riemann_event_protobuf_free (msg->events[i]);
99                 msg->events[i] = NULL;
100         }
102         sfree (msg->events);
103         msg->n_events = 0;
105         sfree (msg);
106 } /* }}} void riemann_msg_protobuf_free */
108 /* host->lock must be held when calling this function. */
109 static int
110 riemann_connect(struct riemann_host *host)
112         int                      e;
113         struct addrinfo         *ai, *res, hints;
114         char const              *node;
115         char const              *service;
117         if (host->flags & F_CONNECT)
118                 return 0;
120         memset(&hints, 0, sizeof(hints));
121         memset(&service, 0, sizeof(service));
122         hints.ai_family = AF_UNSPEC;
123         hints.ai_socktype = host->use_tcp ? SOCK_STREAM : SOCK_DGRAM;
124 #ifdef AI_ADDRCONFIG
125         hints.ai_flags |= AI_ADDRCONFIG;
126 #endif
128         node = (host->node != NULL) ? host->node : RIEMANN_HOST;
129         service = (host->service != NULL) ? host->service : RIEMANN_PORT;
131         if ((e = getaddrinfo(node, service, &hints, &res)) != 0) {
132                 ERROR ("write_riemann plugin: Unable to resolve host \"%s\": %s",
133                         node, gai_strerror(e));
134                 return -1;
135         }
137         host->s = -1;
138         for (ai = res; ai != NULL; ai = ai->ai_next) {
139                 if ((host->s = socket(ai->ai_family,
140                                       ai->ai_socktype,
141                                       ai->ai_protocol)) == -1) {
142                         continue;
143                 }
145                 if (connect(host->s, ai->ai_addr, ai->ai_addrlen) != 0) {
146                         close(host->s);
147                         host->s = -1;
148                         continue;
149                 }
151                 host->flags |= F_CONNECT;
152                 DEBUG("write_riemann plugin: got a succesful connection for: %s:%s",
153                                 node, service);
154                 break;
155         }
157         freeaddrinfo(res);
159         if (host->s < 0) {
160                 WARNING("write_riemann plugin: Unable to connect to Riemann at %s:%s",
161                                 node, service);
162                 return -1;
163         }
164         return 0;
167 /* host->lock must be held when calling this function. */
168 static int
169 riemann_disconnect (struct riemann_host *host)
171         if ((host->flags & F_CONNECT) == 0)
172                 return (0);
174         close (host->s);
175         host->s = -1;
176         host->flags &= ~F_CONNECT;
178         return (0);
181 static int
182 riemann_send(struct riemann_host *host, Msg const *msg)
184         u_char *buffer;
185         size_t  buffer_len;
186         int status;
188         pthread_mutex_lock (&host->lock);
190         status = riemann_connect (host);
191         if (status != 0)
192         {
193                 pthread_mutex_unlock (&host->lock);
194                 return status;
195         }
197         buffer_len = msg__get_packed_size(msg);
198         if (host->use_tcp)
199                 buffer_len += 4;
201         buffer = malloc (buffer_len);
202         if (buffer == NULL) {
203                 pthread_mutex_unlock (&host->lock);
204                 ERROR ("write_riemann plugin: malloc failed.");
205                 return ENOMEM;
206         }
207         memset (buffer, 0, buffer_len);
209         if (host->use_tcp)
210         {
211                 uint32_t length = htonl ((uint32_t) (buffer_len - 4));
212                 memcpy (buffer, &length, 4);
213                 msg__pack(msg, buffer + 4);
214         }
215         else
216         {
217                 msg__pack(msg, buffer);
218         }
220         status = (int) swrite (host->s, buffer, buffer_len);
221         if (status != 0)
222         {
223                 char errbuf[1024];
225                 riemann_disconnect (host);
226                 pthread_mutex_unlock (&host->lock);
228                 ERROR ("write_riemann plugin: Sending to Riemann at %s:%s failed: %s",
229                                 (host->node != NULL) ? host->node : RIEMANN_HOST,
230                                 (host->service != NULL) ? host->service : RIEMANN_PORT,
231                                 sstrerror (errno, errbuf, sizeof (errbuf)));
232                 sfree (buffer);
233                 return -1;
234         }
236         pthread_mutex_unlock (&host->lock);
237         sfree (buffer);
238         return 0;
241 static int riemann_event_add_tag (Event *event, char const *tag) /* {{{ */
243         return (strarray_add (&event->tags, &event->n_tags, tag));
244 } /* }}} int riemann_event_add_tag */
246 static int riemann_event_add_attribute (Event *event, /* {{{ */
247                 char const *key, char const *value)
249         Attribute **new_attributes;
250         Attribute *a;
252         new_attributes = realloc (event->attributes,
253                         sizeof (*event->attributes) * (event->n_attributes + 1));
254         if (new_attributes == NULL)
255         {
256                 ERROR ("write_riemann plugin: realloc failed.");
257                 return (ENOMEM);
258         }
259         event->attributes = new_attributes;
261         a = malloc (sizeof (*a));
262         if (a == NULL)
263         {
264                 ERROR ("write_riemann plugin: malloc failed.");
265                 return (ENOMEM);
266         }
267         attribute__init (a);
269         a->key = strdup (key);
270         if (value != NULL)
271                 a->value = strdup (value);
273         event->attributes[event->n_attributes] = a;
274         event->n_attributes++;
276         return (0);
277 } /* }}} int riemann_event_add_attribute */
279 static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{ */
280                 notification_t const *n)
282         Msg *msg;
283         Event *event;
284         char service_buffer[6 * DATA_MAX_NAME_LEN];
285         char const *severity;
286         notification_meta_t *meta;
287         int i;
289         msg = malloc (sizeof (*msg));
290         if (msg == NULL)
291         {
292                 ERROR ("write_riemann plugin: malloc failed.");
293                 return (NULL);
294         }
295         memset (msg, 0, sizeof (*msg));
296         msg__init (msg);
298         msg->events = malloc (sizeof (*msg->events));
299         if (msg->events == NULL)
300         {
301                 ERROR ("write_riemann plugin: malloc failed.");
302                 sfree (msg);
303                 return (NULL);
304         }
306         event = malloc (sizeof (*event));
307         if (event == NULL)
308         {
309                 ERROR ("write_riemann plugin: malloc failed.");
310                 sfree (msg->events);
311                 sfree (msg);
312                 return (NULL);
313         }
314         memset (event, 0, sizeof (*event));
315         event__init (event);
317         msg->events[0] = event;
318         msg->n_events = 1;
320         event->host = strdup (n->host);
321         event->time = CDTIME_T_TO_TIME_T (n->time);
322         event->has_time = 1;
324         switch (n->severity)
325         {
326                 case NOTIF_OKAY:        severity = "ok"; break;
327                 case NOTIF_WARNING:     severity = "warning"; break;
328                 case NOTIF_FAILURE:     severity = "critical"; break;
329                 default:                severity = "unknown";
330         }
331         event->state = strdup (severity);
333         riemann_event_add_tag (event, "notification");
334         if (n->host[0] != 0)
335                 riemann_event_add_attribute (event, "host", n->host);
336         if (n->plugin[0] != 0)
337                 riemann_event_add_attribute (event, "plugin", n->plugin);
338         if (n->plugin_instance[0] != 0)
339                 riemann_event_add_attribute (event, "plugin_instance",
340                                 n->plugin_instance);
342         if (n->type[0] != 0)
343                 riemann_event_add_attribute (event, "type", n->type);
344         if (n->type_instance[0] != 0)
345                 riemann_event_add_attribute (event, "type_instance",
346                                 n->type_instance);
348         for (i = 0; i < riemann_tags_num; i++)
349                 riemann_event_add_tag (event, riemann_tags[i]);
351         format_name (service_buffer, sizeof (service_buffer),
352                         /* host = */ "", n->plugin, n->plugin_instance,
353                         n->type, n->type_instance);
354         event->service = strdup (&service_buffer[1]);
356         /* Pull in values from threshold */
357         for (meta = n->meta; meta != NULL; meta = meta->next)
358         {
359                 if (strcasecmp ("CurrentValue", meta->name) != 0)
360                         continue;
362                 event->metric_d = meta->nm_value.nm_double;
363                 event->has_metric_d = 1;
364                 break;
365         }
367         DEBUG ("write_riemann plugin: Successfully created protobuf for notification: "
368                         "host = \"%s\", service = \"%s\", state = \"%s\"",
369                         event->host, event->service, event->state);
370         return (msg);
371 } /* }}} Msg *riemann_notification_to_protobuf */
373 static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{ */
374                 data_set_t const *ds,
375                 value_list_t const *vl, size_t index,
376                 gauge_t const *rates)
378         Event *event;
379         char name_buffer[5 * DATA_MAX_NAME_LEN];
380         char service_buffer[6 * DATA_MAX_NAME_LEN];
381         double ttl;
382         int i;
384         event = malloc (sizeof (*event));
385         if (event == NULL)
386         {
387                 ERROR ("write_riemann plugin: malloc failed.");
388                 return (NULL);
389         }
390         memset (event, 0, sizeof (*event));
391         event__init (event);
393         event->host = strdup (vl->host);
394         event->time = CDTIME_T_TO_TIME_T (vl->time);
395         event->has_time = 1;
397         ttl = CDTIME_T_TO_DOUBLE (vl->interval) * host->ttl_factor;
398         event->ttl = (float) ttl;
399         event->has_ttl = 1;
401         riemann_event_add_attribute (event, "plugin", vl->plugin);
402         if (vl->plugin_instance[0] != 0)
403                 riemann_event_add_attribute (event, "plugin_instance",
404                                 vl->plugin_instance);
406         riemann_event_add_attribute (event, "type", vl->type);
407         if (vl->type_instance[0] != 0)
408                 riemann_event_add_attribute (event, "type_instance",
409                                 vl->type_instance);
411         if ((ds->ds[index].type != DS_TYPE_GAUGE) && (rates != NULL))
412         {
413                 char ds_type[DATA_MAX_NAME_LEN];
415                 ssnprintf (ds_type, sizeof (ds_type), "%s:rate",
416                                 DS_TYPE_TO_STRING(ds->ds[index].type));
417                 riemann_event_add_attribute (event, "ds_type", ds_type);
418         }
419         else
420         {
421                 riemann_event_add_attribute (event, "ds_type",
422                                 DS_TYPE_TO_STRING(ds->ds[index].type));
423         }
424         riemann_event_add_attribute (event, "ds_name", ds->ds[index].name);
425         {
426                 char ds_index[DATA_MAX_NAME_LEN];
428                 ssnprintf (ds_index, sizeof (ds_index), "%zu", index);
429                 riemann_event_add_attribute (event, "ds_index", ds_index);
430         }
432         for (i = 0; i < riemann_tags_num; i++)
433                 riemann_event_add_tag (event, riemann_tags[i]);
435         if (ds->ds[index].type == DS_TYPE_GAUGE)
436         {
437                 event->has_metric_d = 1;
438                 event->metric_d = (double) vl->values[index].gauge;
439         }
440         else if (rates != NULL)
441         {
442                 event->has_metric_d = 1;
443                 event->metric_d = (double) rates[index];
444         }
445         else
446         {
447                 event->has_metric_sint64 = 1;
448                 if (ds->ds[index].type == DS_TYPE_DERIVE)
449                         event->metric_sint64 = (int64_t) vl->values[index].derive;
450                 else if (ds->ds[index].type == DS_TYPE_ABSOLUTE)
451                         event->metric_sint64 = (int64_t) vl->values[index].absolute;
452                 else
453                         event->metric_sint64 = (int64_t) vl->values[index].counter;
454         }
456         format_name (name_buffer, sizeof (name_buffer),
457                         /* host = */ "", vl->plugin, vl->plugin_instance,
458                         vl->type, vl->type_instance);
459         if (host->always_append_ds || (ds->ds_num > 1))
460                 ssnprintf (service_buffer, sizeof (service_buffer),
461                                 "%s/%s", &name_buffer[1], ds->ds[index].name);
462         else
463                 sstrncpy (service_buffer, &name_buffer[1],
464                                 sizeof (service_buffer));
466         event->service = strdup (service_buffer);
468         DEBUG ("write_riemann plugin: Successfully created protobuf for metric: "
469                         "host = \"%s\", service = \"%s\"",
470                         event->host, event->service);
471         return (event);
472 } /* }}} Event *riemann_value_to_protobuf */
474 static Msg *riemann_value_list_to_protobuf (struct riemann_host const *host, /* {{{ */
475                 data_set_t const *ds,
476                 value_list_t const *vl)
478         Msg *msg;
479         size_t i;
480         gauge_t *rates = NULL;
482         /* Initialize the Msg structure. */
483         msg = malloc (sizeof (*msg));
484         if (msg == NULL)
485         {
486                 ERROR ("write_riemann plugin: malloc failed.");
487                 return (NULL);
488         }
489         memset (msg, 0, sizeof (*msg));
490         msg__init (msg);
492         /* Set up events. First, the list of pointers. */
493         msg->n_events = (size_t) vl->values_len;
494         msg->events = calloc (msg->n_events, sizeof (*msg->events));
495         if (msg->events == NULL)
496         {
497                 ERROR ("write_riemann plugin: calloc failed.");
498                 riemann_msg_protobuf_free (msg);
499                 return (NULL);
500         }
502         if (host->store_rates)
503         {
504                 rates = uc_get_rate (ds, vl);
505                 if (rates == NULL)
506                 {
507                         ERROR ("write_riemann plugin: uc_get_rate failed.");
508                         riemann_msg_protobuf_free (msg);
509                         return (NULL);
510                 }
511         }
513         for (i = 0; i < msg->n_events; i++)
514         {
515                 msg->events[i] = riemann_value_to_protobuf (host, ds, vl,
516                                 (int) i, rates);
517                 if (msg->events[i] == NULL)
518                 {
519                         riemann_msg_protobuf_free (msg);
520                         sfree (rates);
521                         return (NULL);
522                 }
523         }
525         sfree (rates);
526         return (msg);
527 } /* }}} Msg *riemann_value_list_to_protobuf */
529 static int
530 riemann_notification(const notification_t *n, user_data_t *ud)
532         int                      status;
533         struct riemann_host     *host = ud->data;
534         Msg                     *msg;
536         msg = riemann_notification_to_protobuf (host, n);
537         if (msg == NULL)
538                 return (-1);
540         status = riemann_send (host, msg);
541         if (status != 0)
542                 ERROR ("write_riemann plugin: riemann_send failed with status %i",
543                                 status);
545         riemann_msg_protobuf_free (msg);
546         return (status);
547 } /* }}} int riemann_notification */
549 static int
550 riemann_write(const data_set_t *ds,
551               const value_list_t *vl,
552               user_data_t *ud)
554         int                      status;
555         struct riemann_host     *host = ud->data;
556         Msg                     *msg;
558         msg = riemann_value_list_to_protobuf (host, ds, vl);
559         if (msg == NULL)
560                 return (-1);
562         status = riemann_send (host, msg);
563         if (status != 0)
564                 ERROR ("write_riemann plugin: riemann_send failed with status %i",
565                                 status);
567         riemann_msg_protobuf_free (msg);
568         return status;
571 static void
572 riemann_free(void *p)
574         struct riemann_host     *host = p;
576         if (host == NULL)
577                 return;
579         pthread_mutex_lock (&host->lock);
581         host->reference_count--;
582         if (host->reference_count > 0)
583         {
584                 pthread_mutex_unlock (&host->lock);
585                 return;
586         }
588         riemann_disconnect (host);
590         sfree(host->service);
591         pthread_mutex_destroy (&host->lock);
592         sfree(host);
595 static int
596 riemann_config_node(oconfig_item_t *ci)
598         struct riemann_host     *host = NULL;
599         int                      status = 0;
600         int                      i;
601         oconfig_item_t          *child;
602         char                     callback_name[DATA_MAX_NAME_LEN];
603         user_data_t              ud;
605         if ((host = calloc(1, sizeof (*host))) == NULL) {
606                 ERROR ("write_riemann plugin: calloc failed.");
607                 return ENOMEM;
608         }
609         pthread_mutex_init (&host->lock, NULL);
610         host->reference_count = 1;
611         host->node = NULL;
612         host->service = NULL;
613         host->store_rates = 1;
614         host->always_append_ds = 0;
615         host->use_tcp = 0;
616         host->ttl_factor = RIEMANN_TTL_FACTOR;
618         status = cf_util_get_string (ci, &host->name);
619         if (status != 0) {
620                 WARNING("write_riemann plugin: Required host name is missing.");
621                 riemann_free (host);
622                 return -1;
623         }
625         for (i = 0; i < ci->children_num; i++) {
626                 /*
627                  * The code here could be simplified but makes room
628                  * for easy adding of new options later on.
629                  */
630                 child = &ci->children[i];
631                 status = 0;
633                 if (strcasecmp ("Host", child->key) == 0) {
634                         status = cf_util_get_string (child, &host->node);
635                         if (status != 0)
636                                 break;
637                 } else if (strcasecmp ("Port", child->key) == 0) {
638                         status = cf_util_get_service (child, &host->service);
639                         if (status != 0) {
640                                 ERROR ("write_riemann plugin: Invalid argument "
641                                                 "configured for the \"Port\" "
642                                                 "option.");
643                                 break;
644                         }
645                 } else if (strcasecmp ("Protocol", child->key) == 0) {
646                         char tmp[16];
647                         status = cf_util_get_string_buffer (child,
648                                         tmp, sizeof (tmp));
649                         if (status != 0)
650                         {
651                                 ERROR ("write_riemann plugin: cf_util_get_"
652                                                 "string_buffer failed with "
653                                                 "status %i.", status);
654                                 break;
655                         }
657                         if (strcasecmp ("UDP", tmp) == 0)
658                                 host->use_tcp = 0;
659                         else if (strcasecmp ("TCP", tmp) == 0)
660                                 host->use_tcp = 1;
661                         else
662                                 WARNING ("write_riemann plugin: The value "
663                                                 "\"%s\" is not valid for the "
664                                                 "\"Protocol\" option. Use "
665                                                 "either \"UDP\" or \"TCP\".",
666                                                 tmp);
667                 } else if (strcasecmp ("StoreRates", child->key) == 0) {
668                         status = cf_util_get_boolean (child, &host->store_rates);
669                         if (status != 0)
670                                 break;
671                 } else if (strcasecmp ("AlwaysAppendDS", child->key) == 0) {
672                         status = cf_util_get_boolean (child,
673                                         &host->always_append_ds);
674                         if (status != 0)
675                                 break;
676                 } else if (strcasecmp ("TTLFactor", child->key) == 0) {
677                         double tmp = NAN;
678                         status = cf_util_get_double (child, &tmp);
679                         if (status != 0)
680                                 break;
681                         if (tmp >= 2.0) {
682                                 host->ttl_factor = tmp;
683                         } else if (tmp >= 1.0) {
684                                 NOTICE ("write_riemann plugin: The configured "
685                                                 "TTLFactor is very small "
686                                                 "(%.1f). A value of 2.0 or "
687                                                 "greater is recommended.",
688                                                 tmp);
689                                 host->ttl_factor = tmp;
690                         } else if (tmp > 0.0) {
691                                 WARNING ("write_riemann plugin: The configured "
692                                                 "TTLFactor is too small to be "
693                                                 "useful (%.1f). I'll use it "
694                                                 "since the user knows best, "
695                                                 "but under protest.",
696                                                 tmp);
697                                 host->ttl_factor = tmp;
698                         } else { /* zero, negative and NAN */
699                                 ERROR ("write_riemann plugin: The configured "
700                                                 "TTLFactor is invalid (%.1f).",
701                                                 tmp);
702                         }
703                 } else {
704                         WARNING("write_riemann plugin: ignoring unknown config "
705                                 "option: \"%s\"", child->key);
706                 }
707         }
708         if (status != 0) {
709                 riemann_free (host);
710                 return status;
711         }
713         ssnprintf (callback_name, sizeof (callback_name), "write_riemann/%s",
714                         host->name);
715         ud.data = host;
716         ud.free_func = riemann_free;
718         pthread_mutex_lock (&host->lock);
720         status = plugin_register_write (callback_name, riemann_write, &ud);
721         if (status != 0)
722                 WARNING ("write_riemann plugin: plugin_register_write (\"%s\") "
723                                 "failed with status %i.",
724                                 callback_name, status);
725         else /* success */
726                 host->reference_count++;
728         status = plugin_register_notification (callback_name,
729                         riemann_notification, &ud);
730         if (status != 0)
731                 WARNING ("write_riemann plugin: plugin_register_notification (\"%s\") "
732                                 "failed with status %i.",
733                                 callback_name, status);
734         else /* success */
735                 host->reference_count++;
737         if (host->reference_count <= 1)
738         {
739                 /* Both callbacks failed => free memory.
740                  * We need to unlock here, because riemann_free() will lock.
741                  * This is not a race condition, because we're the only one
742                  * holding a reference. */
743                 pthread_mutex_unlock (&host->lock);
744                 riemann_free (host);
745                 return (-1);
746         }
748         host->reference_count--;
749         pthread_mutex_unlock (&host->lock);
751         return status;
754 static int
755 riemann_config(oconfig_item_t *ci)
757         int              i;
758         oconfig_item_t  *child;
759         int              status;
761         for (i = 0; i < ci->children_num; i++)  {
762                 child = &ci->children[i];
764                 if (strcasecmp("Node", child->key) == 0) {
765                         riemann_config_node (child);
766                 } else if (strcasecmp(child->key, "tag") == 0) {
767                         char *tmp = NULL;
768                         status = cf_util_get_string(child, &tmp);
769                         if (status != 0)
770                                 continue;
772                         strarray_add (&riemann_tags, &riemann_tags_num, tmp);
773                         DEBUG("write_riemann plugin: Got tag: %s", tmp);
774                         sfree (tmp);
775                 } else {
776                         WARNING ("write_riemann plugin: Ignoring unknown "
777                                  "configuration option \"%s\" at top level.",
778                                  child->key);
779                 }
780         }
781         return (0);
784 void
785 module_register(void)
787         plugin_register_complex_config ("write_riemann", riemann_config);
790 /* vim: set sw=8 sts=8 ts=8 noet : */