summaryrefslogtreecommitdiff
path: root/libpod/container_top_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_top_linux.go')
-rw-r--r--libpod/container_top_linux.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go
new file mode 100644
index 000000000..450130add
--- /dev/null
+++ b/libpod/container_top_linux.go
@@ -0,0 +1,30 @@
+// +build linux
+
+package libpod
+
+import (
+ "strconv"
+ "strings"
+
+ "github.com/containers/psgo/ps"
+)
+
+// GetContainerPidInformation returns process-related data of all processes in
+// the container. The output data can be controlled via the `descriptors`
+// argument which expects format descriptors and supports all AIXformat
+// descriptors of ps (1) plus some additional ones to for instance inspect the
+// set of effective capabilities. Eeach element in the returned string slice
+// is a tab-separated string.
+//
+// For more details, please refer to github.com/containers/psgo.
+func (c *Container) GetContainerPidInformation(descriptors []string) ([]string, error) {
+ pid := strconv.Itoa(c.state.PID)
+ format := strings.Join(descriptors, ",")
+ return ps.JoinNamespaceAndProcessInfo(pid, format)
+}
+
+// GetContainerPidInformationDescriptors returns a string slice of all supported
+// format descriptors of GetContainerPidInformation.
+func GetContainerPidInformationDescriptors() ([]string, error) {
+ return ps.ListDescriptors(), nil
+}