diff --git a/TODO.md b/TODO.md index 19f8d019..7718bb19 100644 --- a/TODO.md +++ b/TODO.md @@ -8,6 +8,7 @@ - [ ] Switch to 1.4 and use maps vs hashmaps in sublist - [ ] Sublist better at high concurrency - [ ] Buffer pools/sync pools? +- [ ] IOVec pools and writev for high fanout? - [ ] Add ability to reload config on signal - [ ] NewSource on Rand to lower lock contention on QueueSubs, or redesign! - [ ] Add ENV and variable support to dconf @@ -16,8 +17,9 @@ - [ ] Gossip Protocol for discovery for clustering - [ ] Info updates contain other implicit route servers - [ ] Multi-tenant accounts with isolation of subject space -- [ ] Support sort options for /connz via nats-top - [ ] Add to varz, time for slow consumers, peek connections, memory, etc. +- [X] Add support for / to point to varz, connz, etc.. +- [X] Support sort options for /connz via nats-top - [X] Dropped message statistics (slow consumers) - [X] Add current time to each monitoring endpoint - [X] varz uptime do days and only integer secs diff --git a/server/monitor.go b/server/monitor.go index fe4fccff..83852551 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -153,7 +153,7 @@ func castToSliceString(input []interface{}) []string { // Subsz represents detail information on current connections. type Subsz struct { - SubjectStats sublist.Stats `json:"stats"` + *sublist.Stats } // Routez represents detailed information on current client connections. @@ -224,7 +224,7 @@ func (s *Server) HandleRoutez(w http.ResponseWriter, r *http.Request) { // HandleStats process HTTP requests for subjects stats. func (s *Server) HandleSubsz(w http.ResponseWriter, r *http.Request) { - st := &Subsz{SubjectStats: *s.sl.Stats()} + st := &Subsz{s.sl.Stats()} b, err := json.MarshalIndent(st, "", " ") if err != nil { @@ -282,6 +282,20 @@ func myUptime(d time.Duration) string { return fmt.Sprintf("%ds", tsecs) } +// HandleRoot will show basic info and links to others handlers. +func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "gnatsd monitoring

") + vlink := fmt.Sprintf("http://%s/varz", r.Host) + fmt.Fprintf(w, "%s
", vlink, vlink) + clink := fmt.Sprintf("http://%s/connz", r.Host) + fmt.Fprintf(w, "%s
", clink, clink) + rlink := fmt.Sprintf("http://%s/routez", r.Host) + fmt.Fprintf(w, "%s
", rlink, rlink) + slink := fmt.Sprintf("http://%s/subscriptionsz", r.Host) + fmt.Fprintf(w, "%s
", slink, slink) + fmt.Fprint(w, "") +} + // HandleVarz will process HTTP requests for server information. func (s *Server) HandleVarz(w http.ResponseWriter, r *http.Request) { v := &Varz{Info: &s.info, Options: s.opts, Start: s.start} diff --git a/server/server.go b/server/server.go index 3ba4f46b..76b930cd 100644 --- a/server/server.go +++ b/server/server.go @@ -350,6 +350,9 @@ func (s *Server) StartHTTPMonitoring() { mux := http.NewServeMux() + // Root + mux.HandleFunc("/", s.HandleRoot) + // Varz mux.HandleFunc("/varz", s.HandleVarz)