2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-09-06 18:46:37 +00:00
|
|
|
"encoding/json"
|
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
|
2016-11-14 19:50:16 +00:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2016-09-06 18:46:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ContainerTop shows process information from within a container.
|
2016-11-14 19:50:16 +00:00
|
|
|
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) {
|
|
|
|
var response container.ContainerTopOKBody
|
2016-09-06 18:46:37 +00:00
|
|
|
query := url.Values{}
|
|
|
|
if len(arguments) > 0 {
|
|
|
|
query.Set("ps_args", strings.Join(arguments, " "))
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := cli.get(ctx, "/containers/"+containerID+"/top", query, nil)
|
2019-02-11 12:26:12 +00:00
|
|
|
defer ensureReaderClosed(resp)
|
2016-09-06 18:46:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return response, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&response)
|
|
|
|
return response, err
|
|
|
|
}
|