Added root handler, collapsed subscriptionsz

This commit is contained in:
Derek Collison
2015-08-06 00:58:24 -07:00
parent bb0e6429bd
commit afc1bb05b1
3 changed files with 22 additions and 3 deletions

View File

@@ -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

View File

@@ -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, "<html lang=\"en\">gnatsd monitoring<br/><br/>")
vlink := fmt.Sprintf("http://%s/varz", r.Host)
fmt.Fprintf(w, "<a href=%s>%s</a><br/>", vlink, vlink)
clink := fmt.Sprintf("http://%s/connz", r.Host)
fmt.Fprintf(w, "<a href=%s>%s</a><br/>", clink, clink)
rlink := fmt.Sprintf("http://%s/routez", r.Host)
fmt.Fprintf(w, "<a href=%s>%s</a><br/>", rlink, rlink)
slink := fmt.Sprintf("http://%s/subscriptionsz", r.Host)
fmt.Fprintf(w, "<a href=%s>%s</a><br/>", slink, slink)
fmt.Fprint(w, "</html>")
}
// 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}

View File

@@ -350,6 +350,9 @@ func (s *Server) StartHTTPMonitoring() {
mux := http.NewServeMux()
// Root
mux.HandleFunc("/", s.HandleRoot)
// Varz
mux.HandleFunc("/varz", s.HandleVarz)