From: Sebastian Harl Date: Sat, 25 Apr 2015 11:59:40 +0000 (+0200) Subject: Add support for host. queries. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ab1f53c34612dc816a00055c283884bf316e5f1c;p=sysdb%2Fwebui.git Add support for host. queries. --- diff --git a/server/query.go b/server/query.go index 6f9722c..cb74f22 100644 --- a/server/query.go +++ b/server/query.go @@ -72,8 +72,19 @@ func lookup(req request, s *Server) (*page, error) { } if fields := strings.SplitN(tok, ":", 2); len(fields) == 2 { + // Query: [:] [.]: ... if i == 0 && fields[1] == "" { typ = fields[0] + } else if elems := strings.Split(fields[0], "."); len(elems) > 1 { + objs := elems[:len(elems)-1] + for _, o := range objs { + if o != "host" && o != "service" && o != "metric" { + return nil, fmt.Errorf("Invalid object type %q", o) + } + } + args += fmt.Sprintf(" %s.attribute[%s] = %s", + strings.Join(objs, "."), proto.EscapeString(elems[len(elems)-1]), + proto.EscapeString(fields[1])) } else { args += fmt.Sprintf(" attribute[%s] = %s", proto.EscapeString(fields[0]), proto.EscapeString(fields[1]))