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.
# Host "localhost"
# Port "6379"
# Timeout 1000
# Host "localhost"
# Port "6379"
# Timeout 1000
Host "localhost"
Port "6379"
Timeout 1000
Host "localhost"
Port "6379"
Timeout 1000
</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
</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.
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.
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>
=back
=head2 Plugin C<write_riemann>
/**
* collectd - 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"),
*
* 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>
#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];
struct wr_node_s
{
char name[DATA_MAX_NAME_LEN];
status = FORMAT_VL (ident, sizeof (ident), vl);
if (status != 0)
return (status);
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));
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);
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);
if (rr==NULL)
WARNING("SADD command error. ident:%s message:%s", ident, node->conn->errstr);