github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/lib/container_top.go (about) 1 package lib 2 3 import ( 4 "encoding/json" 5 "net/url" 6 "strings" 7 8 "github.com/docker/docker/api/types" 9 ) 10 11 // ContainerTop shows process information from within a container. 12 func (cli *Client) ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error) { 13 var response types.ContainerProcessList 14 query := url.Values{} 15 if len(arguments) > 0 { 16 query.Set("ps_args", strings.Join(arguments, " ")) 17 } 18 19 resp, err := cli.get("/containers/"+containerID+"/top", query, nil) 20 if err != nil { 21 return response, err 22 } 23 defer ensureReaderClosed(resp) 24 25 err = json.NewDecoder(resp.body).Decode(&response) 26 return response, err 27 }