summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7af18f5)
raw | patch | inline | side by side (parent: 7af18f5)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Thu, 8 Jan 2015 10:06:04 +0000 (11:06 +0100) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Thu, 8 Jan 2015 10:06:04 +0000 (11:06 +0100) |
I find this to be useful when developping new input plugins,
it allows creating a very simple configuration and combined
with `-f` can be used for a very simple workflow.
I'm proposing this, since I think it could be useful for
people wanting to debug their config on local agents as well.
it allows creating a very simple configuration and combined
with `-f` can be used for a very simple workflow.
I'm proposing this, since I think it could be useful for
people wanting to debug their config on local agents as well.
configure.ac | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/write_log.c | [new file with mode: 0644] | patch | blob |
diff --git a/configure.ac b/configure.ac
index 21003f21db3c1d0d95efd3b573fa4a5076bca758..ee18c725ef4340b3f6a06cb094434c2a24619a24 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_PLUGIN([write_graphite], [yes], [Graphite / Carbon output plugin])
AC_PLUGIN([write_http], [$with_libcurl], [HTTP output plugin])
AC_PLUGIN([write_kafka], [$with_librdkafka], [Kafka output plugin])
+AC_PLUGIN([write_log], [yes], [Log output plugin])
AC_PLUGIN([write_mongodb], [$with_libmongoc], [MongoDB output plugin])
AC_PLUGIN([write_redis], [$with_libhiredis], [Redis output plugin])
AC_PLUGIN([write_riemann], [$have_protoc_c], [Riemann output plugin])
write_graphite . . . $enable_write_graphite
write_http . . . . . $enable_write_http
write_kafka . . . . . $enable_write_kafka
+ write_log . . . . . . $enable_write_log
write_mongodb . . . . $enable_write_mongodb
write_redis . . . . . $enable_write_redis
write_riemann . . . . $enable_write_riemann
diff --git a/src/Makefile.am b/src/Makefile.am
index 942e6a06a1af40e1f50c96d35e26de1b38aa0e1b..82e5834ced5841580af52f563ca0140c8c281c4e 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
write_kafka_la_LIBADD = $(BUILD_WITH_LIBRDKAFKA_LIBS)
endif
+if BUILD_PLUGIN_WRITE_LOG
+pkglib_LTLIBRARIES += write_log.la
+write_log_la_SOURCES = write_log.c \
+ utils_format_graphite.c utils_format_graphite.h
+write_log_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
if BUILD_PLUGIN_WRITE_MONGODB
pkglib_LTLIBRARIES += write_mongodb.la
write_mongodb_la_SOURCES = write_mongodb.c
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 95734c266bb89af3dd4d4605cd6519fe40cad0cd..608d38896221648f0ac5bb59da8ccfb20cf30b78 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#@BUILD_PLUGIN_WRITE_GRAPHITE_TRUE@LoadPlugin write_graphite
#@BUILD_PLUGIN_WRITE_HTTP_TRUE@LoadPlugin write_http
#@BUILD_PLUGIN_WRITE_KAFKA_TRUE@LoadPlugin write_kafka
+#@BUILD_PLUGIN_WRITE_LOG_TRUE@LoadPlugin write_log
#@BUILD_PLUGIN_WRITE_MONGODB_TRUE@LoadPlugin write_mongodb
#@BUILD_PLUGIN_WRITE_REDIS_TRUE@LoadPlugin write_redis
#@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@LoadPlugin write_riemann
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 35c90b8641586cf44c7b84f4bf15b8a452a121ea..06264843ea3e0e7c8b8fe5e789f90e3098135081 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=back
+=head2 Plugin C<write_log>
+
+The I<write_log plugin> will send values to the configured log destination.
+It is meant to be used for testing purposes, to ensure that values
+are correctly reported. Values will be formatted in the I<graphite> format.
+
=head2 Plugin C<write_redis>
The I<write_redis plugin> submits values to I<Redis>, a data structure server.
diff --git a/src/write_log.c b/src/write_log.c
--- /dev/null
+++ b/src/write_log.c
@@ -0,0 +1,76 @@
+/**
+ * collectd - src/write_log.c
+ * Copyright (C) 2015 Pierre-Yves Ritschard
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Pierre-Yves Ritschard <pyr at spootnik.org>
+ *
+ **/
+
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
+#include "configfile.h"
+
+#include "utils_format_graphite.h"
+
+/* Folks without pthread will need to disable this plugin. */
+#include <pthread.h>
+
+#include <sys/socket.h>
+#include <netdb.h>
+
+#define WL_BUF_SIZE 8192
+
+static int wl_write_messages (const data_set_t *ds, const value_list_t *vl)
+{
+ char buffer[WL_BUF_SIZE];
+ int status;
+
+ if (0 != strcmp (ds->type, vl->type))
+ {
+ ERROR ("write_log plugin: DS type does not match "
+ "value list type");
+ return -1;
+ }
+
+ memset (buffer, 0, sizeof (buffer));
+ status = format_graphite (buffer, sizeof (buffer), ds, vl,
+ NULL, NULL, '_', 0);
+ if (status != 0) /* error message has been printed already. */
+ return (status);
+
+ INFO ("write_log values:\n%s", buffer);
+
+ return (0);
+} /* int wl_write_messages */
+
+static int wl_write (const data_set_t *ds, const value_list_t *vl,
+ user_data_t *user_data)
+{
+ int status;
+
+ status = wl_write_messages (ds, vl);
+
+ return (status);
+}
+
+void module_register (void)
+{
+ plugin_register_write ("write_log", wl_write, NULL);
+}
+
+/* vim: set sw=4 ts=4 sts=4 tw=78 et : */