]
)
- AM_INIT_AUTOMAKE(dist-bzip2)
+ AM_INIT_AUTOMAKE([tar-pax dist-bzip2])
AC_LANG(C)
AC_PREFIX_DEFAULT("/opt/collectd")
AC_HEADER_DIRENT
AC_HEADER_STDBOOL
-AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h)
+AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)
# For ping library
AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
then
AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
+ # For the battery plugin
+ AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
+[
+#if HAVE_IOKIT_IOKITLIB_H
+# include <IOKit/IOKitLib.h>
+#endif
+#if HAVE_IOKIT_IOTYPES_H
+# include <IOKit/IOTypes.h>
+#endif
+])
+
fi
+
AC_CHECK_HEADERS(sys/sysctl.h, [], [],
[
#if HAVE_SYS_TYPES_H
fi
# For hddtemp module
-AC_CHECK_HEADERS(linux/major.h libgen.h)
+AC_CHECK_HEADERS(linux/major.h)
# For md module (Linux only)
if test "x$ac_system" = "xLinux"
have_linux_raid_md_u_h="no"
fi
-# For the battery plugin
-AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
-[
-#if HAVE_IOKIT_IOKITLIB_H
-# include <IOKit/IOKitLib.h>
-#endif
-#if HAVE_IOKIT_IOTYPES_H
-# include <IOKit/IOTypes.h>
-#endif
-])
-
# For the swap module
have_linux_wireless_h="no"
if test "x$ac_system" = "xLinux"
AC_CHECK_HEADERS(netinet/ip_compat.h)
have_net_pfvar_h="no"
- AC_CHECK_HEADERS(net/pfvar.h, [have_net_pfvar_h="yes"])
+ AC_CHECK_HEADERS(net/pfvar.h,
+ [have_net_pfvar_h="yes"],
+ [have_net_pfvar_h="no"],
+ [
+ #if HAVE_SYS_IOCTL_H
+ # include <sys/ioctl.h>
+ #endif
+ #if HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif
+ #if HAVE_NET_IF_H
+ # include <net/if.h>
+ #endif
+ ])
# For the multimeter plugin
have_termios_h="no"
AC_PLUGIN([wireless], [$plugin_wireless], [Wireless statistics])
AC_PLUGIN([write_graphite], [yes], [Graphite / Carbon output plugin])
AC_PLUGIN([write_http], [$with_libcurl], [HTTP output plugin])
-AC_PLUGIN([write_redis], [$with_libcredis], [Redis output plugin])
AC_PLUGIN([write_mongodb], [$with_libmongoc], [MongoDB output plugin])
+AC_PLUGIN([write_redis], [$with_libcredis], [Redis output plugin])
+AC_PLUGIN([write_riemann], [$have_protoc_c], [Riemann output plugin])
AC_PLUGIN([xmms], [$with_libxmms], [XMMS statistics])
AC_PLUGIN([zfs_arc], [$plugin_zfs_arc], [ZFS ARC statistics])
wireless . . . . . . $enable_wireless
write_graphite . . . $enable_write_graphite
write_http . . . . . $enable_write_http
- write_redis . . . . . $enable_write_redis
write_mongodb . . . . $enable_write_mongodb
+ write_redis . . . . . $enable_write_redis
+ write_riemann . . . . $enable_write_riemann
xmms . . . . . . . . $enable_xmms
zfs_arc . . . . . . . $enable_zfs_arc
collectd_DEPENDENCIES += write_redis.la
endif
+if BUILD_PLUGIN_WRITE_RIEMANN
+BUILT_SOURCES += riemann.pb-c.c riemann.pb-c.h
+CLEANFILES += riemann.pb-c.c riemann.pb-c.h
+pkglib_LTLIBRARIES += write_riemann.la
+write_riemann_la_SOURCES = write_riemann.c riemann.pb-c.c
+write_riemann_la_LDFLAGS = -module -avoid-version
+write_riemann_la_LIBADD = -lprotobuf-c
+collectd_LDADD += "-dlopen" write_riemann.la
+collectd_DEPENDENCIES += write_riemann.la
+endif
+
if BUILD_PLUGIN_XMMS
pkglib_LTLIBRARIES += xmms.la
xmms_la_SOURCES = xmms.c
#collectd_1_SOURCES = collectd.pod
-EXTRA_DIST = types.db pinba.proto
+EXTRA_DIST = types.db pinba.proto riemann.proto
EXTRA_DIST += collectd.conf.pod \
collectd-email.pod \
fi
pinba.pb-c.c pinba.pb-c.h: pinba.proto
- protoc-c --c_out . pinba.proto
+ protoc-c -I$(srcdir) --c_out . $(srcdir)/pinba.proto
+riemann.pb-c.c riemann.pb-c.h: riemann.proto
+ protoc-c --c_out . riemann.proto
+
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
};
static int def_queries_num = STATIC_ARRAY_SIZE (def_queries);
- static c_psql_database_t *databases = NULL;
- static size_t databases_num = 0;
+ static c_psql_database_t **databases = NULL;
+ static size_t databases_num = 0;
- static udb_query_t **queries = NULL;
- static size_t queries_num = 0;
+ static udb_query_t **queries = NULL;
+ static size_t queries_num = 0;
- static c_psql_writer_t *writers = NULL;
- static size_t writers_num = 0;
+ static c_psql_writer_t *writers = NULL;
+ static size_t writers_num = 0;
static int c_psql_begin (c_psql_database_t *db)
{
static c_psql_database_t *c_psql_database_new (const char *name)
{
- c_psql_database_t *db;
+ c_psql_database_t **tmp;
+ c_psql_database_t *db;
- db = (c_psql_database_t *)realloc (databases,
- (databases_num + 1) * sizeof (*db));
+ db = (c_psql_database_t *)malloc (sizeof(*db));
if (NULL == db) {
log_err ("Out of memory.");
return NULL;
}
- databases = db;
- db = databases + databases_num;
+ tmp = (c_psql_database_t **)realloc (databases,
+ (databases_num + 1) * sizeof (*databases));
+ if (NULL == tmp) {
+ log_err ("Out of memory.");
+ sfree (db);
+ return NULL;
+ }
+
+ databases = tmp;
+ databases[databases_num] = db;
++databases_num;
db->conn = NULL;
sfree (db->service);
/* don't care about freeing or reordering the 'databases' array
- * this is done in 'shutdown' */
+ * this is done in 'shutdown'; also, don't free the database instance
+ * object just to make sure that in case anybody accesses it before
+ * shutdown won't segfault */
return;
} /* c_psql_database_delete */
c_psql_connect (db);
}
- /* "ping" */
- PQclear (PQexec (db->conn, "SELECT 42;"));
-
if (CONNECTION_OK != PQstatus (db->conn)) {
PQreset (db->conn);
if (PGRES_TUPLES_OK != PQresultStatus (res)) {
pthread_mutex_lock (&db->db_lock);
+ if ((CONNECTION_OK != PQstatus (db->conn))
+ && (0 == c_psql_check_connection (db))) {
+ PQclear (res);
+ return c_psql_exec_query (db, q, prep_area);
+ }
+
log_err ("Failed to execute SQL query: %s",
PQerrorMessage (db->conn));
log_info ("SQL query was: %s",
__attribute__((unused)) const char *ident,
user_data_t *ud)
{
- c_psql_database_t *dbs = databases;
+ c_psql_database_t **dbs = databases;
size_t dbs_num = databases_num;
size_t i;
if ((ud != NULL) && (ud->data != NULL)) {
- dbs = ud->data;
+ dbs = (void *)&ud->data;
dbs_num = 1;
}
for (i = 0; i < dbs_num; ++i) {
- c_psql_database_t *db = dbs + i;
+ c_psql_database_t *db = dbs[i];
/* don't commit if the timeout is larger than the regular commit
* interval as in that case all requested data has already been
plugin_unregister_read_group ("postgresql");
for (i = 0; i < databases_num; ++i) {
- c_psql_database_t *db = databases + i;
+ c_psql_database_t *db = databases[i];
if (db->writers_num > 0) {
char cb_name[DATA_MAX_NAME_LEN];
plugin_unregister_flush (cb_name);
plugin_unregister_write (cb_name);
}
+
+ sfree (db);
}
udb_query_free (queries, queries_num);
* Copyright (C) 2011 Scott Sanders
* Copyright (C) 2009 Paul Sadauskas
* Copyright (C) 2009 Doug MacEachern
- * Copyright (C) 2007-2012 Florian octo Forster
+ * Copyright (C) 2007-2013 Florian octo Forster
*
* 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
#include "configfile.h"
#include "utils_cache.h"
+ #include "utils_complain.h"
#include "utils_parse_option.h"
#include "utils_format_graphite.h"
{
int sock_fd;
+ char *name;
+
char *node;
char *service;
char *prefix;
char *postfix;
char escape_char;
- _Bool store_rates;
- _Bool separate_instances;
- _Bool always_append_ds;
+ unsigned int format_flags;
char send_buf[WG_SEND_BUF_SIZE];
size_t send_buf_free;
cdtime_t send_buf_init_time;
pthread_mutex_t send_lock;
+ c_complain_t init_complaint;
};
if (cb->sock_fd < 0)
{
char errbuf[1024];
- ERROR ("write_graphite plugin: Connecting to %s:%s failed. "
+ c_complain (LOG_ERR, &cb->init_complaint,
+ "write_graphite plugin: Connecting to %s:%s failed. "
"The last error was: %s", node, service,
sstrerror (errno, errbuf, sizeof (errbuf)));
close (cb->sock_fd);
return (-1);
}
+ else
+ {
+ c_release (LOG_INFO, &cb->init_complaint,
+ "write_graphite plugin: Successfully connected to %s:%s.",
+ node, service);
+ }
wg_reset_buffer (cb);
close(cb->sock_fd);
cb->sock_fd = -1;
+ sfree(cb->name);
sfree(cb->node);
sfree(cb->service);
sfree(cb->prefix);
status = wg_callback_init (cb);
if (status != 0)
{
- ERROR ("write_graphite plugin: wg_callback_init failed.");
+ /* An error message has already been printed. */
pthread_mutex_unlock (&cb->send_lock);
return (-1);
}
status = wg_callback_init (cb);
if (status != 0)
{
- ERROR ("write_graphite plugin: wg_callback_init failed.");
+ /* An error message has already been printed. */
pthread_mutex_unlock (&cb->send_lock);
return (-1);
}
static int wg_write_messages (const data_set_t *ds, const value_list_t *vl,
struct wg_callback *cb)
{
- char buffer[4096];
+ char buffer[WG_SEND_BUF_SIZE];
int status;
if (0 != strcmp (ds->type, vl->type))
memset (buffer, 0, sizeof (buffer));
status = format_graphite (buffer, sizeof (buffer), ds, vl,
- cb->prefix, cb->postfix, cb->escape_char, cb->store_rates);
+ cb->prefix, cb->postfix, cb->escape_char, cb->format_flags);
if (status != 0) /* error message has been printed already. */
return (status);
+ /* Send the message to graphite */
wg_send_message (buffer, cb);
if (status != 0)
{
- ERROR ("write_graphite plugin: wg_send_message failed "
- "with status %i.", status);
+ /* An error message has already been printed. */
return (status);
}
return (0);
}
-static int wg_config_carbon (oconfig_item_t *ci)
+static int wg_config_node (oconfig_item_t *ci)
{
struct wg_callback *cb;
user_data_t user_data;
}
memset (cb, 0, sizeof (*cb));
cb->sock_fd = -1;
+ cb->name = NULL;
cb->node = NULL;
cb->service = NULL;
cb->prefix = NULL;
cb->postfix = NULL;
cb->escape_char = WG_DEFAULT_ESCAPE;
- cb->store_rates = 1;
+ cb->format_flags = GRAPHITE_STORE_RATES;
+ /* FIXME: Legacy configuration syntax. */
+ if (strcasecmp ("Carbon", ci->key) != 0)
+ {
+ int status = cf_util_get_string (ci, &cb->name);
+ if (status != 0)
+ {
+ wg_callback_free (cb);
+ return (status);
+ }
+ }
+
pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);
+ C_COMPLAIN_INIT (&cb->init_complaint);
for (i = 0; i < ci->children_num; i++)
{
else if (strcasecmp ("Postfix", child->key) == 0)
cf_util_get_string (child, &cb->postfix);
else if (strcasecmp ("StoreRates", child->key) == 0)
- cf_util_get_boolean (child, &cb->store_rates);
+ cf_util_get_flag (child, &cb->format_flags,
+ GRAPHITE_STORE_RATES);
else if (strcasecmp ("SeparateInstances", child->key) == 0)
- cf_util_get_boolean (child, &cb->separate_instances);
+ cf_util_get_flag (child, &cb->format_flags,
+ GRAPHITE_SEPARATE_INSTANCES);
else if (strcasecmp ("AlwaysAppendDS", child->key) == 0)
- cf_util_get_boolean (child, &cb->always_append_ds);
+ cf_util_get_flag (child, &cb->format_flags,
+ GRAPHITE_ALWAYS_APPEND_DS);
else if (strcasecmp ("EscapeCharacter", child->key) == 0)
config_set_char (&cb->escape_char, child);
else
}
}
- ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s/%s",
- cb->node != NULL ? cb->node : WG_DEFAULT_NODE,
- cb->service != NULL ? cb->service : WG_DEFAULT_SERVICE);
+ /* FIXME: Legacy configuration syntax. */
+ if (cb->name == NULL)
+ ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s/%s",
+ cb->node != NULL ? cb->node : WG_DEFAULT_NODE,
+ cb->service != NULL ? cb->service : WG_DEFAULT_SERVICE);
+ else
+ ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s",
+ cb->name);
memset (&user_data, 0, sizeof (user_data));
user_data.data = cb;
{
oconfig_item_t *child = ci->children + i;
- if (strcasecmp ("Carbon", child->key) == 0)
- wg_config_carbon (child);
+ if (strcasecmp ("Node", child->key) == 0)
+ wg_config_node (child);
+ /* FIXME: Remove this legacy mode in version 6. */
+ else if (strcasecmp ("Carbon", child->key) == 0)
+ wg_config_node (child);
else
{
ERROR ("write_graphite plugin: Invalid configuration "