From 9118acb268fb13bcf619e4301db09d1ab34b97d1 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 17 Jan 2025 00:20:38 +0900 Subject: [PATCH] removed the extra stats table --- server-ctl.go | 9 +-------- server.go | 10 ---------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/server-ctl.go b/server-ctl.go index 24f39ce..6841812 100644 --- a/server-ctl.go +++ b/server-ctl.go @@ -34,8 +34,6 @@ type json_out_server_stats struct { ServerPeers int64 `json:"server-peers"` SshProxySessions int64 `json:"ssh-proxy-session"` - - Extra map[string]int64 `json:"extra"` } // ------------------------------------ @@ -359,8 +357,7 @@ func (ctl *server_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) case http.MethodGet: var stats json_out_server_stats var mstat runtime.MemStats - var k string - var v int64 + runtime.ReadMemStats(&mstat) stats.CPUs = runtime.NumCPU() stats.Goroutines = runtime.NumGoroutine() @@ -372,10 +369,6 @@ func (ctl *server_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) stats.ServerRoutes = s.stats.routes.Load() stats.ServerPeers = s.stats.peers.Load() stats.SshProxySessions = s.stats.ssh_proxy_sessions.Load() - s.stats.extra_mtx.Lock() - stats.Extra = make(map[string]int64, len(s.stats.extra)) - for k, v = range s.stats.extra { stats.Extra[k] = v } - s.stats.extra_mtx.Unlock() status_code = WriteJsonRespHeader(w, http.StatusOK) if err = je.Encode(stats); err != nil { goto oops } diff --git a/server.go b/server.go index 3e7c9fe..99ad80e 100644 --- a/server.go +++ b/server.go @@ -93,9 +93,6 @@ type Server struct { routes atomic.Int64 peers atomic.Int64 ssh_proxy_sessions atomic.Int64 - - extra_mtx sync.Mutex - extra map[string]int64 } wpx_resp_tf ServerWpxResponseTransformer @@ -1145,7 +1142,6 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs s.stats.routes.Store(0) s.stats.peers.Store(0) s.stats.ssh_proxy_sessions.Store(0) - s.stats.extra = make(map[string]int64, 64) return &s, nil @@ -1661,12 +1657,6 @@ func (s *Server) WriteLog(id string, level LogLevel, fmtstr string, args ...inte s.log.Write(id, level, fmtstr, args...) } -func (s *Server) SetExtraStat(key string, val int64) { - s.stats.extra_mtx.Lock() - s.stats.extra[key] = val - s.stats.extra_mtx.Unlock() -} - func (s *Server) AddCtlHandler(path string, handler ServerHttpHandler) { s.ctl_mux.Handle(s.ctl_prefix + "/_ctl" + path, s.wrap_http_handler(handler)) }