summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/pods.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/varlinkapi/pods.go')
-rw-r--r--pkg/varlinkapi/pods.go33
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)
+}