summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b914b8b)
raw | patch | inline | side by side (parent: b914b8b)
author | Florian Forster <octo@collectd.org> | |
Thu, 25 Jun 2015 20:11:17 +0000 (22:11 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 25 Jun 2015 20:13:23 +0000 (22:13 +0200) |
Make the code match the documentation and use the prefix for the set of all
metrics, too. Also add documentation for the "Prefix" option and let the
default prefix be set at compile time.
metrics, too. Also add documentation for the "Prefix" option and let the
default prefix be set at compile time.
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/write_redis.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 5a4c46741349677692d0fc8ea53f7da80c054b6b..bafdddb4eee6e981f786bf6736fad9130c2428a8 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Host "localhost"
# Port "6379"
# Timeout 1000
+# Prefix "collectd/"
# </Node>
#</Plugin>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 9412ed3718e9abd62fbc11eec952d7329704b446..b2aab2139e1ce45633e2004609955c7e5b5a13f6 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Host "localhost"
Port "6379"
Timeout 1000
- Prefix "examplePrefix"
+ Prefix "collectd/"
</Node>
</Plugin>
Values are submitted to I<Sorted Sets>, using the metric name as the key, and
the timestamp as the score. Retrieving a date range can then be done using the
C<ZRANGEBYSCORE> I<Redis> command. Additionnally, all the identifiers of these
-I<Sorted Sets> are kept in a I<Set> called C<collectd/values> or C<Prefix/values> if a Prefix was specified and can be
-retrieved using the C<SMEMBERS> I<Redis> command. See
+I<Sorted Sets> are kept in a I<Set> called C<collectd/values> (or
+C<${prefix}/values> if the B<Prefix> option was specified) and can be retrieved
+using the C<SMEMBERS> I<Redis> command. See
L<http://redis.io/commands#sorted_set> and L<http://redis.io/commands#set> for
details.
The B<Timeout> option sets the socket connection timeout, in milliseconds.
+=item B<Prefix> I<Prefix>
+
+Prefix used when constructing the name of the I<Sorted Sets> and the I<Set>
+containing all metrics. Defaults to C<collectd/>, so metrics will have names
+like C<collectd/cpu-0/cpu-user>. When setting this to something different, it
+is recommended but not required to include a trailing slash in I<Prefix>.
+
=back
=head2 Plugin C<write_riemann>
diff --git a/src/write_redis.c b/src/write_redis.c
index 24bcfc8cc0c9c0e8c1be4aa4356804b533ea2683..909f51d51aa23ff396da9c259430618efd45043b 100644 (file)
--- a/src/write_redis.c
+++ b/src/write_redis.c
/**
* collectd - src/write_redis.c
- * Copyright (C) 2010 Florian Forster
+ * Copyright (C) 2010-2015 Florian Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include <sys/time.h>
#include <hiredis/hiredis.h>
+#ifndef REDIS_DEFAULT_PREFIX
+# define REDIS_DEFAULT_PREFIX "collectd/"
+#endif
+
struct wr_node_s
{
char name[DATA_MAX_NAME_LEN];
status = FORMAT_VL (ident, sizeof (ident), vl);
if (status != 0)
return (status);
- if (node->prefix == NULL) {
- ssnprintf (key, sizeof (key), "collectd/%s", ident);
- }
- else {
- ssnprintf (key, sizeof (key), "%s/%s", node->prefix, ident);
- }
+ ssnprintf (key, sizeof (key), "%s%s",
+ (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX,
+ ident);
ssnprintf (time, sizeof (time), "%.9f", CDTIME_T_TO_DOUBLE(vl->time));
memset (value, 0, sizeof (value));
if (rr==NULL)
WARNING("ZADD command error. key:%s message:%s", key, node->conn->errstr);
- rr = redisCommand (node->conn, "SADD collectd/values %s", ident);
+ rr = redisCommand (node->conn, "SADD %svalues %s",
+ (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX,
+ ident);
if (rr==NULL)
WARNING("SADD command error. ident:%s message:%s", ident, node->conn->errstr);