mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Added root handler, collapsed subscriptionsz
This commit is contained in:
4
TODO.md
4
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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -350,6 +350,9 @@ func (s *Server) StartHTTPMonitoring() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Root
|
||||
mux.HandleFunc("/", s.HandleRoot)
|
||||
|
||||
// Varz
|
||||
mux.HandleFunc("/varz", s.HandleVarz)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user