summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e39a0c2)
raw | patch | inline | side by side (parent: e39a0c2)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 14 May 2015 22:43:12 +0000 (00:43 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 14 May 2015 22:43:12 +0000 (00:43 +0200) |
src/core/store.c | patch | blob | history | |
t/unit/core/store_expr_test.c | patch | blob | history | |
t/unit/core/store_json_test.c | patch | blob | history | |
t/unit/frontend/query_test.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index cb3189d72245690941c6d010a41dfa6d5da7f927..ea30da90116d9925cd148e39f7577e346503ba42 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
{
sdb_host_t *host;
sdb_avltree_t *services;
+ sdb_data_t d;
int status = 0;
if (sdb_plugin_store_service(hostname, name, last_update))
status = -1;
+
+ /* record the hostname as an attribute */
+ d.type = SDB_TYPE_STRING;
+ d.data.string = SDB_OBJ(host)->name;
+ if (sdb_store_service_attr(hostname, name, "hostname", &d, last_update))
+ status = -1;
return status;
} /* sdb_store_service */
sdb_store_obj_t *obj = NULL;
sdb_host_t *host;
sdb_metric_t *metric;
+ sdb_data_t d;
sdb_avltree_t *metrics;
if (sdb_plugin_store_metric(hostname, name, store, last_update))
status = -1;
+
+ /* record the hostname as an attribute */
+ d.type = SDB_TYPE_STRING;
+ d.data.string = SDB_OBJ(host)->name;
+ if (sdb_store_metric_attr(hostname, name, "hostname", &d, last_update))
+ status = -1;
return status;
} /* sdb_store_metric */
index 5de5fdd0b4e877b1501de2662eb0e22fc91d4d5f..48c128c0573b5943e2fdfec200958be71e51bb64 100644 (file)
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
"a", SDB_SERVICE, "s1", NULL,
{
+ { SDB_TYPE_STRING, { .string = "hostname" } },
{ SDB_TYPE_STRING, { .string = "k1" } },
{ 0 },
{ 0 },
{ 0 },
- { 0 },
- }, 1,
+ }, 2,
},
{
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
"a", SDB_SERVICE, "s1", "age >= 0s",
{
+ { SDB_TYPE_STRING, { .string = "hostname" } },
{ SDB_TYPE_STRING, { .string = "k1" } },
{ 0 },
{ 0 },
{ 0 },
- { 0 },
- }, 1,
+ }, 2,
},
{
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
"b", SDB_METRIC, "m2", NULL,
{
+ { SDB_TYPE_STRING, { .string = "hostname" } },
{ SDB_TYPE_STRING, { .string = "k1" } },
{ SDB_TYPE_STRING, { .string = "k2" } },
{ 0 },
{ 0 },
- { 0 },
- }, 2,
+ }, 3,
},
{
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
"b", SDB_METRIC, "m2", "age >= 0s",
{
+ { SDB_TYPE_STRING, { .string = "hostname" } },
{ SDB_TYPE_STRING, { .string = "k1" } },
{ SDB_TYPE_STRING, { .string = "k2" } },
{ 0 },
{ 0 },
- { 0 },
- }, 2,
+ }, 3,
},
{
{ SDB_OBJECT_INIT, TYPED_EXPR, -1, &namer, NULL, ATTRS }, true,
index ff6a18edc3ae8f095988129231430b893a0a5b03..704ad067fc52d9fba04a8ea5bbe901a3013583c6 100644 (file)
struct {
struct {
- sdb_store_matcher_t *(*m)(sdb_store_expr_t *,
- sdb_store_expr_t *);
+ sdb_store_matcher_t *(*m)(sdb_store_expr_t *, sdb_store_expr_t *);
int field;
sdb_data_t value;
} filter;
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": 42, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"], "
"\"services\": ["
"{\"name\": \"s1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []},"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]},"
"{\"name\": \"s2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
"\"services\": ["
"{\"name\": \"s1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []},"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]},"
"{\"name\": \"s2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": 42, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { NULL, 0, SDB_DATA_INIT },
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
index 0f25493b397aa8991179553a27644c11a88a8d51..73f3042ee9516a8605346393ab4ca456cdb2dd5c 100644 (file)
"\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": [], " \
"\"attributes\": [" \
+ "{\"name\": \"hostname\", \"value\": \"h1\", " \
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
+ "\"update_interval\": \"0s\", \"backends\": []}," \
"{\"name\": \"k3\", \"value\": 42, " \
"\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": []}]}," \
"{\"name\": \"m2\", \"timeseries\": false, " \
"\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
- "\"update_interval\": \"0s\", \"backends\": []}]}"
+ "\"update_interval\": \"0s\", \"backends\": [], " \
+ "\"attributes\": [" \
+ "{\"name\": \"hostname\", \"value\": \"h1\", " \
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
+ "\"update_interval\": \"0s\", \"backends\": []}]}]}"
#define SERVICE_H2_S1 \
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": [], " \
"\"services\": [" \
"{\"name\": \"s1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", " \
- "\"update_interval\": \"0s\", \"backends\": []}]}"
+ "\"update_interval\": \"0s\", \"backends\": [], " \
+ "\"attributes\": [" \
+ "{\"name\": \"hostname\", \"value\": \"h2\", " \
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
+ "\"update_interval\": \"0s\", \"backends\": []}]}]}"
#define METRIC_H1_M1 \
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": [], " \
"\"attributes\": [" \
+ "{\"name\": \"hostname\", \"value\": \"h1\", " \
+ "\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
+ "\"update_interval\": \"0s\", \"backends\": []}," \
"{\"name\": \"k3\", \"value\": 42, " \
"\"last_update\": \"1970-01-01 00:00:00 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": []}]}]}"
/* hosts */
{
SDB_HOST, "h1", NULL, NULL,
- 0, SDB_CONNECTION_DATA, 851, HOST_H1,
+ 0, SDB_CONNECTION_DATA, 1110, HOST_H1,
},
{
SDB_HOST, "h1", NULL, "age >= 0s", /* always matches */
- 0, SDB_CONNECTION_DATA, 851, HOST_H1,
+ 0, SDB_CONNECTION_DATA, 1110, HOST_H1,
},
{
SDB_HOST, "h1", NULL, "age < 0s", /* never matches */
/* services */
{
SDB_SERVICE, "h2", "s1", NULL,
- 0, SDB_CONNECTION_DATA, 218, SERVICE_H2_S1,
+ 0, SDB_CONNECTION_DATA, 356, SERVICE_H2_S1,
},
{
SDB_SERVICE, "h2", "s1", "age >= 0s", /* always matches */
- 0, SDB_CONNECTION_DATA, 218, SERVICE_H2_S1,
+ 0, SDB_CONNECTION_DATA, 356, SERVICE_H2_S1,
},
{
SDB_SERVICE, "h2", "s1", "age < 0s", /* never matches */
/* metrics */
{
SDB_METRIC, "h1", "m1", NULL,
- 0, SDB_CONNECTION_DATA, 368, METRIC_H1_M1,
+ 0, SDB_CONNECTION_DATA, 489, METRIC_H1_M1,
},
{
SDB_METRIC, "h1", "m1", "age >= 0s", /* always matches */
- 0, SDB_CONNECTION_DATA, 368, METRIC_H1_M1,
+ 0, SDB_CONNECTION_DATA, 489, METRIC_H1_M1,
},
{
SDB_METRIC, "h1", "m1", "age < 0s", /* never matches */