mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 19:14:41 -07:00
show basic jetstream info in varz and server info
This commit is contained in:
committed by
Derek Collison
parent
6cd07c7cf0
commit
fc6d8826f5
@@ -124,13 +124,14 @@ type accNumConnsReq struct {
|
||||
|
||||
// ServerInfo identifies remote servers.
|
||||
type ServerInfo struct {
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
ID string `json:"id"`
|
||||
Cluster string `json:"cluster,omitempty"`
|
||||
Version string `json:"ver"`
|
||||
Seq uint64 `json:"seq"`
|
||||
Time time.Time `json:"time"`
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
ID string `json:"id"`
|
||||
Cluster string `json:"cluster,omitempty"`
|
||||
Version string `json:"ver"`
|
||||
Seq uint64 `json:"seq"`
|
||||
JetStream bool `json:"jetstream"`
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
// ClientInfo is detailed information about the client forming a connection.
|
||||
@@ -223,6 +224,7 @@ RESET:
|
||||
host := s.info.Host
|
||||
servername := s.info.Name
|
||||
seqp := &s.sys.seq
|
||||
js := s.js != nil
|
||||
var cluster string
|
||||
if s.gateway.enabled {
|
||||
cluster = s.getGatewayName()
|
||||
@@ -251,6 +253,7 @@ RESET:
|
||||
pm.si.Seq = atomic.AddUint64(seqp, 1)
|
||||
pm.si.Version = VERSION
|
||||
pm.si.Time = time.Now()
|
||||
pm.si.JetStream = js
|
||||
}
|
||||
var b []byte
|
||||
if pm.msg != nil {
|
||||
|
||||
@@ -984,6 +984,7 @@ type Varz struct {
|
||||
Cluster ClusterOptsVarz `json:"cluster,omitempty"`
|
||||
Gateway GatewayOptsVarz `json:"gateway,omitempty"`
|
||||
LeafNode LeafNodeOptsVarz `json:"leaf,omitempty"`
|
||||
JetStream JetStreamVarz `json:"jetstream,omitempty"`
|
||||
TLSTimeout float64 `json:"tls_timeout"`
|
||||
WriteDeadline time.Duration `json:"write_deadline"`
|
||||
Start time.Time `json:"start"`
|
||||
@@ -1008,6 +1009,14 @@ type Varz struct {
|
||||
ConfigLoadTime time.Time `json:"config_load_time"`
|
||||
}
|
||||
|
||||
// JetStreamVarz contains basic runtime information about jetstream
|
||||
type JetStreamVarz struct {
|
||||
MaxMemory int64 `json:"max_memory,omitempty"`
|
||||
MaxStore int64 `json:"max_store,omitempty"`
|
||||
StoreDir string `json:"store_dir,omitempty"`
|
||||
Accounts int `json:"accounts,omitempty"`
|
||||
}
|
||||
|
||||
// ClusterOptsVarz contains monitoring cluster information
|
||||
type ClusterOptsVarz struct {
|
||||
Host string `json:"addr,omitempty"`
|
||||
@@ -1211,6 +1220,17 @@ func (s *Server) createVarz(pcpu float64, rss int64) *Varz {
|
||||
}
|
||||
varz.LeafNode.Remotes = rlna
|
||||
}
|
||||
|
||||
if s.js != nil {
|
||||
s.js.mu.RLock()
|
||||
varz.JetStream = JetStreamVarz{
|
||||
MaxMemory: s.js.config.MaxMemory,
|
||||
MaxStore: s.js.config.MaxStore,
|
||||
StoreDir: s.js.config.StoreDir,
|
||||
}
|
||||
s.js.mu.RUnlock()
|
||||
}
|
||||
|
||||
// Finish setting it up with fields that can be updated during
|
||||
// configuration reload and runtime.
|
||||
s.updateVarzConfigReloadableFields(varz)
|
||||
@@ -1315,6 +1335,12 @@ func (s *Server) updateVarzRuntimeFields(v *Varz, forceUpdate bool, pcpu float64
|
||||
}
|
||||
}
|
||||
gw.RUnlock()
|
||||
|
||||
if s.js != nil {
|
||||
s.js.mu.RLock()
|
||||
v.JetStream.Accounts = len(s.js.accounts)
|
||||
s.js.mu.RUnlock()
|
||||
}
|
||||
}
|
||||
|
||||
// HandleVarz will process HTTP requests for server information.
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
// Allow dynamic profiling.
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
|
||||
Reference in New Issue
Block a user