summaryrefslogtreecommitdiffstats
path: root/proxy
diff options
context:
space:
mode:
authorVladimir Lavor <vlavor@cisco.com>2020-10-29 12:56:24 +0100
committerOndrej Fabry <ofabry@cisco.com>2020-10-30 12:39:24 +0000
commitb74e3b37479a7fa763bed1f2c76de612ee51dcbc (patch)
tree3a632ae21f54ba41a480b27d97c7332240ff257c /proxy
parent0f46871b4cc45f2c3bd5bdb0aa0f7615795a2c6d (diff)
Stats API: added GetMemory()
Retrieved numbers relate to the statseg heap. Change-Id: I72750183db3524481918c71c993b39e65c28ddb6 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Diffstat (limited to 'proxy')
-rw-r--r--proxy/client.go10
-rw-r--r--proxy/server.go4
2 files changed, 14 insertions, 0 deletions
diff --git a/proxy/client.go b/proxy/client.go
index 6f29c71..aea9a94 100644
--- a/proxy/client.go
+++ b/proxy/client.go
@@ -117,6 +117,16 @@ func (s *StatsClient) GetBufferStats(bufStats *api.BufferStats) error {
return nil
}
+func (s *StatsClient) GetMemoryStats(memStats *api.MemoryStats) error {
+ req := StatsRequest{StatsType: "memory"}
+ resp := StatsResponse{MemStats: new(api.MemoryStats)}
+ if err := s.rpc.Call("StatsRPC.GetStats", req, &resp); err != nil {
+ return err
+ }
+ *memStats = *resp.MemStats
+ return nil
+}
+
type BinapiClient struct {
rpc *rpc.Client
timeout time.Duration
diff --git a/proxy/server.go b/proxy/server.go
index 50a0077..21d8e1b 100644
--- a/proxy/server.go
+++ b/proxy/server.go
@@ -55,6 +55,7 @@ type StatsResponse struct {
IfaceStats *api.InterfaceStats
ErrStats *api.ErrorStats
BufStats *api.BufferStats
+ MemStats *api.MemoryStats
}
// StatsRPC is a RPC server for proxying client request to api.StatsProvider.
@@ -200,6 +201,9 @@ func (s *StatsRPC) GetStats(req StatsRequest, resp *StatsResponse) error {
case "buffer":
resp.BufStats = new(api.BufferStats)
return s.statsConn.GetBufferStats(resp.BufStats)
+ case "memory":
+ resp.MemStats = new(api.MemoryStats)
+ return s.statsConn.GetMemoryStats(resp.MemStats)
default:
return fmt.Errorf("unknown stats type: %s", req.StatsType)
}