func init() { servenv.OnRun(func() { servenv.AddStatusPart("Tablet", tabletTemplate, func() interface{} { return map[string]interface{}{ "Tablet": agent.Tablet(), "BlacklistedTables": agent.BlacklistedTables(), "DisableQueryService": agent.DisableQueryService(), } }) if agent.IsRunningHealthCheck() { servenv.AddStatusFuncs(template.FuncMap{ "github_com_youtube_vitess_health_html_name": healthHTMLName, }) servenv.AddStatusPart("Health", healthTemplate, func() interface{} { return &healthStatus{Records: agent.History.Records()} }) } tabletserver.AddStatusPart() servenv.AddStatusPart("Binlog Player", binlogTemplate, func() interface{} { return agent.BinlogPlayerMap.Status() }) if onStatusRegistered != nil { onStatusRegistered() } }) }
func init() { servenv.OnRun(func() { servenv.AddStatusPart("Topology Cache", topoTemplate, func() interface{} { return resilientSrvTopoServer.CacheStatus() }) servenv.AddStatusPart("Stats", statsTemplate, func() interface{} { return nil }) }) }
func initStatusHandling() { // code to serve /status workerTemplate := loadTemplate("worker", workerStatusHTML) http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) { currentWorkerMutex.Lock() wrk := currentWorker logger := currentMemoryLogger done := currentDone currentWorkerMutex.Unlock() data := make(map[string]interface{}) if wrk != nil { data["Status"] = wrk.StatusAsHTML() select { case <-done: data["Done"] = true default: } if logger != nil { data["Logs"] = template.HTML(strings.Replace(logger.String(), "\n", "</br>\n", -1)) } else { data["Logs"] = template.HTML("See console for logs</br>\n") } } executeTemplate(w, workerTemplate, data) }) // add the section in statusz that does auto-refresh of status div servenv.AddStatusPart("Worker Status", workerStatusPartHTML, func() interface{} { return nil }) // reset handler http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) { currentWorkerMutex.Lock() wrk := currentWorker done := currentDone currentWorkerMutex.Unlock() // no worker, we go to the menu if wrk == nil { http.Redirect(w, r, "/", http.StatusTemporaryRedirect) return } // check the worker is really done select { case <-done: currentWorkerMutex.Lock() currentWorker = nil currentMemoryLogger = nil currentDone = nil currentWorkerMutex.Unlock() http.Redirect(w, r, "/", http.StatusTemporaryRedirect) default: httpError(w, "worker still executing", nil) } }) }
// AddStatusPart registers the status part for the status page. func AddStatusPart() { servenv.AddStatusPart("Queryservice", queryserviceStatusTemplate, func() interface{} { status := queryserviceStatus{ State: SqlQueryRpcService.GetState(), } rates := QPSRates.Get() if qps, ok := rates["All"]; ok && len(qps) > 0 { status.CurrentQPS = qps[0] } return status }) }