summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4065234)
raw | patch | inline | side by side (parent: 4065234)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 6 Nov 2014 09:10:06 +0000 (10:10 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 6 Nov 2014 09:10:06 +0000 (10:10 +0100) |
The old implementation didn't work when querying services or metrics and for
hosts it's the same as querying the 'name' field.
hosts it's the same as querying the 'name' field.
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 2e5274469057b12ac195997982e4018df727268e..6791806b0bf473593330a7c057b75644268d7d0e 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
sdb_object_deref(SDB_OBJ($3)); $3 = NULL;
}
|
- HOST_T
- {
- /* XXX: this doesn't work correctly when not
- * querying hosts => use <type>.<field> instead
- * and let the analyzer verify <type> */
- $$ = sdb_store_expr_fieldvalue(SDB_FIELD_NAME);
- }
- |
field
{
$$ = sdb_store_expr_fieldvalue($1);
index c96f7abea9c94cc8432a3ed27ff39268b3c60cd6..8b25ed3cc062627115f32bdb45e62abde3a54b66 100755 (executable)
echo "$output" | grep -F 'host2.example.com' && exit 1
output="$( run_sysdb -H "$SOCKET_FILE" \
- -c "LOOKUP hosts MATCHING host =~ 'example.com'" )"
+ -c "LOOKUP hosts MATCHING name =~ 'example.com'" )"
echo "$output" \
| grep -F '"host1.example.com"' \
| grep -F '"host2.example.com"'
index c256b232ae049096eaace1a86652ff84a77b6e5d..dcf72fa5947638b12879f9d228185a1c004bde0b 100644 (file)
int expected;
} golden_data[] = {
/* TODO: check the name of the expected hosts */
- { "host = 'a'", NULL, 1 },
- { "host = 'a'", "host = 'x'", 0 }, /* filter never matches */
- { "host = 'a'",
+ { "name = 'a'", NULL, 1 },
+ { "name = 'a'", "name = 'x'", 0 }, /* filter never matches */
+ { "name = 'a'",
"NOT attribute['x'] = ''", 1 }, /* filter always matches */
- { "host =~ 'a|b'", NULL, 2 },
- { "host =~ 'host'", NULL, 0 },
- { "host =~ '.'", NULL, 3 },
+ { "name =~ 'a|b'", NULL, 2 },
+ { "name =~ 'host'", NULL, 0 },
+ { "name =~ '.'", NULL, 3 },
{ "ANY metric = 'm1'", NULL, 2 },
- { "ANY metric= 'm1'", "host = 'x'", 0 }, /* filter never matches */
+ { "ANY metric= 'm1'", "name = 'x'", 0 }, /* filter never matches */
{ "ANY metric = 'm1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY metric =~ 'm'", NULL, 2 },
{ "ALL metric !~ 'm'", NULL, 1 },
{ "ANY metric =~ 'x'", NULL, 0 },
{ "ANY service = 's1'", NULL, 2 },
- { "ANY service = 's1'", "host = 'x'", 0 }, /* filter never matches */
+ { "ANY service = 's1'", "name = 'x'", 0 }, /* filter never matches */
{ "ANY service = 's1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY service =~ 's'", NULL, 2 },
{ "ANY service =~ 's'", "name !~ '1'", 2 },
{ "ANY service !~ 's'", NULL, 0 },
{ "ANY attribute = 'k1'", NULL, 2 },
- { "ANY attribute = 'k1'", "host = 'x'",0 }, /* filter never matches */
+ { "ANY attribute = 'k1'", "name = 'x'",0 }, /* filter never matches */
{ "ANY attribute = 'k1'",
"NOT attribute['x'] = ''", 2 }, /* filter always matches */
{ "ANY attribute =~ 'k'", NULL, 2 },
index 947ef710cb44f232a208fcf99d0b7d6d1663c1be..b3d5c8bf5b6c45eb9933170bdda72a7e57d0237a 100644 (file)
{ "LOOKUP hosts", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host = 'host'", -1, 1, CONNECTION_LOOKUP },
+ "name = 'host'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING NOT "
- "host = 'host'", -1, 1, CONNECTION_LOOKUP },
+ "name = 'host'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' AND "
+ "name =~ 'p' AND "
"ANY service =~ 'p'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING NOT "
- "host =~ 'p' AND "
+ "name =~ 'p' AND "
"ANY service =~ 'p'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' AND "
+ "name =~ 'p' AND "
"ANY service =~ 'p' OR "
"ANY service =~ 'r'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING NOT "
- "host =~ 'p' AND "
+ "name =~ 'p' AND "
"ANY service =~ 'p' OR "
"ANY service =~ 'r'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' "
+ "name =~ 'p' "
"FILTER age > 1D", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' "
+ "name =~ 'p' "
"FILTER age > 1D AND "
"interval < 240s" , -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' "
+ "name =~ 'p' "
"FILTER NOT age>1D", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host =~ 'p' "
+ "name =~ 'p' "
"FILTER age>"
"interval", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP services", -1, 1, CONNECTION_LOOKUP },
/* string constants */
{ "LOOKUP hosts MATCHING "
- "host = ''''", -1, 1, CONNECTION_LOOKUP },
+ "name = ''''", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host = '''foo'", -1, 1, CONNECTION_LOOKUP },
+ "name = '''foo'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host = 'f''oo'", -1, 1, CONNECTION_LOOKUP },
+ "name = 'f''oo'", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host = 'foo'''", -1, 1, CONNECTION_LOOKUP },
+ "name = 'foo'''", -1, 1, CONNECTION_LOOKUP },
{ "LOOKUP hosts MATCHING "
- "host = '''", -1, -1, 0 },
+ "name = '''", -1, -1, 0 },
/* numeric constants */
{ "LOOKUP hosts MATCHING "
{ "LIST", -1, -1, 0 },
{ "LIST foo", -1, -1, 0 },
{ "LIST hosts MATCHING "
- "host = 'host'", -1, -1, 0 },
+ "name = 'host'", -1, -1, 0 },
{ "LIST foo FILTER "
"age > 60s", -1, -1, 0 },
{ "FETCH host 'host' MATCHING "
- "host = 'host'", -1, -1, 0 },
+ "name = 'host'", -1, -1, 0 },
{ "FETCH service 'host'",-1, -1, 0 },
{ "FETCH metric 'host'", -1, -1, 0 },
{ "FETCH host "
{ "LOOKUP foo", -1, -1, 0 },
{ "LOOKUP foo MATCHING "
- "host = 'host'", -1, -1, 0 },
+ "name = 'host'", -1, -1, 0 },
{ "LOOKUP foo FILTER "
"age > 60s", -1, -1, 0 },
{ "LOOKUP foo MATCHING "
- "host = 'host' FILTER "
+ "name = 'host' FILTER "
"age > 60s", -1, -1, 0 },
{ "LOOKUP hosts MATCHING "
"attribute['foo'] <= "
{ "", -1, -1 },
/* match hosts by name */
- { "host < 'localhost'", -1, MATCHER_LT },
- { "host <= 'localhost'", -1, MATCHER_LE },
- { "host = 'localhost'", -1, MATCHER_EQ },
- { "host != 'localhost'", -1, MATCHER_NE },
- { "host >= 'localhost'", -1, MATCHER_GE },
- { "host > 'localhost'", -1, MATCHER_GT },
- { "host =~ 'host'", -1, MATCHER_REGEX },
- { "host !~ 'host'", -1, MATCHER_NREGEX },
- { "host = 'localhost' -- foo", -1, MATCHER_EQ },
- { "host = 'host' <garbage>", 13, MATCHER_EQ },
- { "host &^ 'localhost'", -1, -1 },
+ { "name < 'localhost'", -1, MATCHER_LT },
+ { "name <= 'localhost'", -1, MATCHER_LE },
+ { "name = 'localhost'", -1, MATCHER_EQ },
+ { "name != 'localhost'", -1, MATCHER_NE },
+ { "name >= 'localhost'", -1, MATCHER_GE },
+ { "name > 'localhost'", -1, MATCHER_GT },
+ { "name =~ 'host'", -1, MATCHER_REGEX },
+ { "name !~ 'host'", -1, MATCHER_NREGEX },
+ { "name = 'localhost' -- foo", -1, MATCHER_EQ },
+ { "name = 'host' <garbage>", 13, MATCHER_EQ },
+ { "name &^ 'localhost'", -1, -1 },
/* match hosts by service */
{ "ANY service < 'name'", -1, MATCHER_ANY },
{ "ANY service <= 'name'", -1, MATCHER_ANY },
{ "ANY attribute !~ 'pattern'", -1, MATCHER_ANY },
{ "ANY attribute &^ 'pattern'", -1, -1 },
/* composite expressions */
- { "host =~ 'pattern' AND "
+ { "name =~ 'pattern' AND "
"ANY service =~ 'pattern'", -1, MATCHER_AND },
- { "host =~ 'pattern' OR "
+ { "name =~ 'pattern' OR "
"ANY service =~ 'pattern'", -1, MATCHER_OR },
- { "NOT host = 'host'", -1, MATCHER_NOT },
+ { "NOT name = 'host'", -1, MATCHER_NOT },
/* numeric expressions */
{ "attribute['foo'] < 123", -1, MATCHER_LT },
{ "attribute['foo'] <= 123", -1, MATCHER_LE },
{ "'be' IN backend", -1, MATCHER_IN },
/* check operator precedence */
- { "host = 'name' OR "
+ { "name = 'name' OR "
"ANY service = 'name' AND "
"ANY attribute = 'name' OR "
"attribute['foo'] = 'bar'", -1, MATCHER_OR },
- { "host = 'name' AND "
+ { "name = 'name' AND "
"ANY service = 'name' AND "
"ANY attribute = 'name' OR "
"attribute['foo'] = 'bar'", -1, MATCHER_OR },
- { "host = 'name' AND "
+ { "name = 'name' AND "
"ANY service = 'name' OR "
"ANY attribute = 'name' AND "
"attribute['foo'] = 'bar'", -1, MATCHER_OR },
- { "(host = 'name' OR "
+ { "(name = 'name' OR "
"ANY service = 'name') AND "
"(ANY attribute = 'name' OR "
"attribute['foo'] = 'bar')", -1, MATCHER_AND },
- { "NOT host = 'name' OR "
+ { "NOT name = 'name' OR "
"ANY service = 'name'", -1, MATCHER_OR },
- { "NOT host = 'name' OR "
+ { "NOT name = 'name' OR "
"NOT ANY service = 'name'", -1, MATCHER_OR },
- { "NOT (host = 'name' OR "
+ { "NOT (name = 'name' OR "
"NOT ANY service = 'name')", -1, MATCHER_NOT },
/* syntax errors */