summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2e0fdac)
raw | patch | inline | side by side (parent: 2e0fdac)
author | Sebastian Pfahl <eryx@gmx.net> | |
Fri, 10 Jul 2015 11:33:11 +0000 (11:33 +0000) | ||
committer | Sebastian Pfahl <eryx@gmx.net> | |
Mon, 13 Jul 2015 05:48:33 +0000 (05:48 +0000) |
src/collectd.conf.pod | patch | blob | history | |
src/write_redis.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index b2aab2139e1ce45633e2004609955c7e5b5a13f6..87844e1308398c3c725037c4558c48ffdebcd2d2 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Port "6379"
Timeout 1000
Prefix "collectd/"
+ Database 1
</Node>
</Plugin>
@@ -7503,7 +7504,8 @@ 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 the B<Prefix> option was specified) and can be retrieved
-using the C<SMEMBERS> I<Redis> command. See
+using the C<SMEMBERS> I<Redis> command. You can specify the database to use
+with the B<Database> parameter (default is C<0>). See
L<http://redis.io/commands#sorted_set> and L<http://redis.io/commands#set> for
details.
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>.
+=item B<Database> I<Index>
+
+This index selects the redis database to use for writing operations. Defaults to C<0>.
+
=back
=head2 Plugin C<write_riemann>
diff --git a/src/write_redis.c b/src/write_redis.c
index fa58ad2ace61667322f606a08b380bdb63b7b188..7ba476c92fa2164322c4d3ad5ba73b64ea67e322 100644 (file)
--- a/src/write_redis.c
+++ b/src/write_redis.c
int port;
struct timeval timeout;
char *prefix;
+ int database;
redisContext *conn;
pthread_mutex_t lock;
pthread_mutex_unlock (&node->lock);
return (-1);
}
+
+ rr = redisCommand(node->conn, "SELECT %d", node->database);
+ if (rr == NULL)
+ WARNING("SELECT command error. database:%d message:%s", node->database, node->conn->errstr);
+ else
+ freeReplyObject (rr);
}
rr = redisCommand (node->conn, "ZADD %s %s %s", key, time, value);
node->timeout.tv_usec = 1000;
node->conn = NULL;
node->prefix = NULL;
+ node->database = 0;
pthread_mutex_init (&node->lock, /* attr = */ NULL);
status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name));
else if (strcasecmp ("Prefix", child->key) == 0) {
status = cf_util_get_string (child, &node->prefix);
}
+ else if (strcasecmp ("Database", child->key) == 0) {
+ status = cf_util_get_int (child, &node->database);
+ }
else
WARNING ("write_redis plugin: Ignoring unknown config option \"%s\".",
child->key);