Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
grpc :[RPC]Add the StatsContainer api for events cli
Browse files Browse the repository at this point in the history
Add `StatsContainer` API to display container events
Fixes: #221

Signed-off-by: c00416947 <caihaomin@huawei.com>
  • Loading branch information
jshachm committed Apr 25, 2018
1 parent bf6f367 commit 29d945c
Show file tree
Hide file tree
Showing 7 changed files with 5,649 additions and 2,028 deletions.
28 changes: 28 additions & 0 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,34 @@ func (a *agentGRPC) ListProcesses(ctx context.Context, req *pb.ListProcessesRequ
return resp, nil
}

func (a *agentGRPC) StatsContainer(ctx context.Context, req *pb.StatsContainerRequest) (*pb.StatsContainerResponse, error){
c, err := a.sandbox.getContainer(req.ContainerId)
if err != nil {
return nil, err
}

stats ,err := c.container.Stats()
if err != nil {
return nil ,err
}

data,err := json.Marshal(stats.CgroupStats)
if err != nil {
return nil ,err
}

var cgroupStats pb.CgroupStats
err = json.Unmarshal(data,&cgroupStats)
if err != nil {
return nil,err
}
resp := &pb.StatsContainerResponse{
CgroupStats:&cgroupStats,
}

return resp, nil
}

func (a *agentGRPC) RemoveContainer(ctx context.Context, req *pb.RemoveContainerRequest) (*gpb.Empty, error) {
ctr, err := a.sandbox.getContainer(req.ContainerId)
if err != nil {
Expand Down
Loading

0 comments on commit 29d945c

Please sign in to comment.