2 * collectd - src/write_log.c
3 * Copyright (C) 2015 Pierre-Yves Ritschard
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Pierre-Yves Ritschard <pyr at spootnik.org>
26 #include "configfile.h"
28 #include "utils_format_graphite.h"
30 /* Folks without pthread will need to disable this plugin. */
33 #include <sys/socket.h>
36 #define WL_BUF_SIZE 8192
38 static int wl_write_messages (const data_set_t *ds, const value_list_t *vl)
40 char buffer[WL_BUF_SIZE];
43 if (0 != strcmp (ds->type, vl->type))
45 ERROR ("write_log plugin: DS type does not match "
50 memset (buffer, 0, sizeof (buffer));
51 status = format_graphite (buffer, sizeof (buffer), ds, vl,
53 if (status != 0) /* error message has been printed already. */
56 INFO ("write_log values:\n%s", buffer);
59 } /* int wl_write_messages */
61 static int wl_write (const data_set_t *ds, const value_list_t *vl,
62 user_data_t *user_data)
66 status = wl_write_messages (ds, vl);
71 void module_register (void)
73 plugin_register_write ("write_log", wl_write, NULL);
76 /* vim: set sw=4 ts=4 sts=4 tw=78 et : */