diff options
author | haircommander <pehunt@redhat.com> | 2018-08-21 16:32:21 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-23 15:58:08 +0000 |
commit | 3df6332a65b203b8fab106e9856a263f24b956a0 (patch) | |
tree | c59bb7045c27043061c8fcf27dfdc87e802df48f /pkg/varlinkapi | |
parent | 7310697b73ff5ea8f58f24672c802f1e5e9dda3c (diff) | |
download | podman-3df6332a65b203b8fab106e9856a263f24b956a0.tar.gz podman-3df6332a65b203b8fab106e9856a263f24b956a0.tar.bz2 podman-3df6332a65b203b8fab106e9856a263f24b956a0.zip |
Add GetPodStats to varlink
Signed-off-by: haircommander <pehunt@redhat.com>
Closes: #1319
Approved by: baude
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r-- | pkg/varlinkapi/pods.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/varlinkapi/pods.go b/pkg/varlinkapi/pods.go index 640dd665e..75733db11 100644 --- a/pkg/varlinkapi/pods.go +++ b/pkg/varlinkapi/pods.go @@ -187,3 +187,36 @@ func (i *LibpodAPI) RemovePod(call iopodman.VarlinkCall, name string, force bool return call.ReplyRemovePod(pod.ID()) } + +// GetPodStats ... +func (i *LibpodAPI) GetPodStats(call iopodman.VarlinkCall, name string) error { + pod, err := i.Runtime.LookupPod(name) + if err != nil { + return call.ReplyPodNotFound(name) + } + prevStats := make(map[string]*libpod.ContainerStats) + podStats, err := pod.GetPodStats(prevStats) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + containersStats := make([]iopodman.ContainerStats, 0) + for ctrID, containerStats := range podStats { + cs := iopodman.ContainerStats{ + Id: ctrID, + Name: containerStats.Name, + Cpu: containerStats.CPU, + Cpu_nano: int64(containerStats.CPUNano), + System_nano: int64(containerStats.SystemNano), + Mem_usage: int64(containerStats.MemUsage), + Mem_limit: int64(containerStats.MemLimit), + Mem_perc: containerStats.MemPerc, + Net_input: int64(containerStats.NetInput), + Net_output: int64(containerStats.NetOutput), + Block_input: int64(containerStats.BlockInput), + Block_output: int64(containerStats.BlockOutput), + Pids: int64(containerStats.PIDs), + } + containersStats = append(containersStats, cs) + } + return call.ReplyGetPodStats(pod.ID(), containersStats) +} |