Port "6379"
Timeout 2000
<Query "LLEN myqueue">
+ Database 0
Type "queue_length"
Instance "myqueue"
<Query>
The B<Query> block identifies a query to execute against the redis server.
There may be an arbitrary number of queries to execute.
+=item B<Database> I<Index>
+
+This index selects the redis database to use for queries. Defaults
+to C<0>.
+
=item B<Type> I<Collectd type>
Within a query definition, a valid collectd type to use as when submitting
#define REDIS_DEF_PASSWD ""
#define REDIS_DEF_PORT 6379
#define REDIS_DEF_TIMEOUT 2000
-#define REDIS_DEF_DB_COUNT 16
+#define REDIS_DEF_DB_COUNT 256
#define MAX_REDIS_NODE_NAME 64
#define MAX_REDIS_PASSWD_LENGTH 512
#define MAX_REDIS_VAL_SIZE 256
char query[MAX_REDIS_QUERY];
char type[DATA_MAX_NAME_LEN];
char instance[DATA_MAX_NAME_LEN];
+ int database;
+
redis_query_t *next;
};
(void)sstrncpy(rq->instance, rq->query, sizeof(rq->instance));
replace_special(rq->instance, sizeof(rq->instance));
+ rq->database = 0;
+
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *option = ci->children + i;
} else if (strcasecmp("Instance", option->key) == 0) {
status =
cf_util_get_string_buffer(option, rq->instance, sizeof(rq->instance));
+ } else if (strcasecmp("Database", option->key) == 0) {
+ status = cf_util_get_int(option, &rq->database);
+ if (rq->database < 0) {
+ WARNING("redis plugin: The \"Database\" option must be positive "
+ "integer or zero");
+ status = -1;
+ }
} else {
WARNING("redis plugin: unknown configuration option: %s", option->key);
status = -1;
return -1;
}
+ if ((rr = redisCommand(rh, "SELECT %d", rq->database)) == NULL) {
+ WARNING("redis plugin: unable to switch to database `%d' on node `%s'.",
+ rq->database, rn->name);
+ return -1;
+ }
+
if ((rr = redisCommand(rh, rq->query)) == NULL) {
WARNING("redis plugin: unable to carry out query `%s'.", rq->query);
return -1;