2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 14:46:37 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
|
2016-11-14 14:50:16 -05:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2016-09-06 14:46:37 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ContainerTop shows process information from within a container.
|
2016-11-14 14:50:16 -05:00
|
|
|
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) {
|
|
|
|
var response container.ContainerTopOKBody
|
2016-09-06 14:46:37 -04: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)
|
|
|
|
if err != nil {
|
|
|
|
return response, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&response)
|
|
|
|
ensureReaderClosed(resp)
|
|
|
|
return response, err
|
|
|
|
}
|