// Problems provides list of instances with known problems func (this *HttpAPI) Agents(params martini.Params, r render.Render, req *http.Request) { if !config.Config.ServeAgentsHttp { r.JSON(200, &APIResponse{Code: ERROR, Message: "Agents not served"}) return } agents, err := agent.ReadAgents() if err != nil { r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) return } r.JSON(200, agents) }
// AgentsInstances provides list of assumed MySQL instances (host:port) func (this *HttpAgentsAPI) AgentsInstances(params martini.Params, r render.Render, req *http.Request) string { agents, err := agent.ReadAgents() hostnames := []string{} for _, agent := range agents { hostnames = append(hostnames, fmt.Sprintf("%s:%d", agent.Hostname, agent.MySQLPort)) } if err != nil { r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) return "" } if req.URL.Query().Get("format") == "txt" { return strings.Join(hostnames, "\n") } else { r.JSON(200, hostnames) } return "" }