diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-04-25 15:01:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 15:01:39 -0700 |
commit | e2d7e325f42b58290275b6bc25f1b0c64378aff4 (patch) | |
tree | 779caad2670afddd36621cbee9198a913d4b7c3f /libpod | |
parent | a01c62fcbde1afdc77aa05b71c3c84ddacf7fc55 (diff) | |
parent | c4dd7c5813078acbe871aae37644bfff3163d160 (diff) | |
download | podman-e2d7e325f42b58290275b6bc25f1b0c64378aff4.tar.gz podman-e2d7e325f42b58290275b6bc25f1b0c64378aff4.tar.bz2 podman-e2d7e325f42b58290275b6bc25f1b0c64378aff4.zip |
Merge pull request #3014 from baude/remotetop
enable podman remote top
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_top_linux.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go index 9b0f156b5..b370495fe 100644 --- a/libpod/container_top_linux.go +++ b/libpod/container_top_linux.go @@ -7,8 +7,22 @@ import ( "strings" "github.com/containers/psgo" + "github.com/pkg/errors" ) +// Top gathers statistics about the running processes in a container. It returns a +// []string for output +func (c *Container) Top(descriptors []string) ([]string, error) { + conStat, err := c.State() + if err != nil { + return nil, errors.Wrapf(err, "unable to look up state for %s", c.ID()) + } + if conStat != ContainerStateRunning { + return nil, errors.Errorf("top can only be used on running containers") + } + return c.GetContainerPidInformation(descriptors) +} + // 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 |