diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index 10dd803..989759a 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -89,12 +89,11 @@ func main() { Tmpl = tmpl http.HandleFunc("/", showChecks) + http.HandleFunc("/check", showCheck) http.HandleFunc("/checks", showChecks) - http.HandleFunc("/hosts", showHosts) http.HandleFunc("/groups", showGroups) http.HandleFunc("/action", checkAction) http.HandleFunc("/unhandled/checks", showChecks) - http.HandleFunc("/unhandled/hosts", showHosts) http.HandleFunc("/unhandled/groups", showGroups) http.ListenAndServe(config.Listen, nil) } @@ -196,6 +195,17 @@ func showChecks(w http.ResponseWriter, r *http.Request) { } idx := 0 params := []interface{}{} + if search, found := r.URL.Query()["search"]; found { + idx += 1 + // Add the search for nodes. As hostnames or FQDNs are really weird, the + // string needs to be split up by some characters. The input string needs + // to be split up too, so all is done here. + // TODO move this into a proper index and add more to search. + where = append(where, fmt.Sprintf( + `to_tsvector('english', regexp_replace(n.name, '[.-/]', ' ', 'g')) @@ + to_tsquery('english', regexp_replace($%d, '[.-/]', ' & ', 'g'))`, idx)) + params = append(params, search[0]) + } if id, found := r.URL.Query()["node_id"]; found { idx += 1 where = append(where, fmt.Sprintf("n.id = $%d::int", idx)) @@ -254,7 +264,8 @@ func showChecks(w http.ResponseWriter, r *http.Request) { return } -func showHosts(w http.ResponseWriter, r *http.Request) { +// showCheck loads shows the notifications for a specific check. +func showCheck(w http.ResponseWriter, r *http.Request) { } func showGroups(w http.ResponseWriter, r *http.Request) { @@ -349,12 +360,37 @@ var ( var ( Templates = map[string]string{ - "header": ` + "header": ` {{ .Title }}