Skip to content

Commit

Permalink
Added root handler, collapsed subscriptionsz
Browse files Browse the repository at this point in the history
  • Loading branch information
derekcollison committed Aug 6, 2015
1 parent bb0e642 commit afc1bb0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 16 additions & 2 deletions server/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ func (s *Server) StartHTTPMonitoring() {

mux := http.NewServeMux()

// Root
mux.HandleFunc("/", s.HandleRoot)

// Varz
mux.HandleFunc("/varz", s.HandleVarz)

Expand Down

0 comments on commit afc1bb0

Please sign in to comment.