diff options
author | baude <bbaude@redhat.com> | 2019-04-24 15:57:37 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-04-25 14:44:14 -0500 |
commit | c4dd7c5813078acbe871aae37644bfff3163d160 (patch) | |
tree | 779caad2670afddd36621cbee9198a913d4b7c3f /libpod | |
parent | a01c62fcbde1afdc77aa05b71c3c84ddacf7fc55 (diff) | |
download | podman-c4dd7c5813078acbe871aae37644bfff3163d160.tar.gz podman-c4dd7c5813078acbe871aae37644bfff3163d160.tar.bz2 podman-c4dd7c5813078acbe871aae37644bfff3163d160.zip |
enable podman remote top
add the ability for the remote client to display a container's running
processes.
Signed-off-by: baude <bbaude@redhat.com>
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 |