diff --git a/api.go b/api.go index fb7bbc4614..f6f54cfa41 100644 --- a/api.go +++ b/api.go @@ -250,12 +250,12 @@ func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r return nil } -func getContainersProc(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersTop(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if vars == nil { return fmt.Errorf("Missing parameter") } name := vars["name"] - procsStr, err := srv.ContainerProc(name) + procsStr, err := srv.ContainerTop(name) if err != nil { return err } @@ -859,7 +859,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) { "/containers/{name:.*}/export": getContainersExport, "/containers/{name:.*}/changes": getContainersChanges, "/containers/{name:.*}/json": getContainersByName, - "/containers/{name:.*}/proc": getContainersProc, + "/containers/{name:.*}/top": getContainersTop, }, "POST": { "/auth": postAuth, diff --git a/api_params.go b/api_params.go index 89fe180d02..b371ca314f 100644 --- a/api_params.go +++ b/api_params.go @@ -26,7 +26,7 @@ type APIInfo struct { SwapLimit bool `json:",omitempty"` } -type APIProc struct { +type APITop struct { PID string Tty string Time string diff --git a/api_test.go b/api_test.go index f0ce4bf9f7..069a7e5818 100644 --- a/api_test.go +++ b/api_test.go @@ -475,7 +475,7 @@ func TestGetContainersChanges(t *testing.T) { } } -func TestGetContainersProc(t *testing.T) { +func TestGetContainersTop(t *testing.T) { runtime, err := newTestRuntime() if err != nil { t.Fatal(err) @@ -509,10 +509,10 @@ func TestGetContainersProc(t *testing.T) { } r := httptest.NewRecorder() - if err := getContainersProc(srv, APIVERSION, r, nil, map[string]string{"name": container.ID}); err != nil { + if err := getContainersTop(srv, APIVERSION, r, nil, map[string]string{"name": container.ID}); err != nil { t.Fatal(err) } - procs := []APIProc{} + procs := []APITop{} if err := json.Unmarshal(r.Body.Bytes(), &procs); err != nil { t.Fatal(err) } diff --git a/commands.go b/commands.go index 73f9b949a9..719326d79e 100644 --- a/commands.go +++ b/commands.go @@ -90,7 +90,7 @@ func (cli *DockerCli) CmdHelp(args ...string) error { {"login", "Register or Login to the docker registry server"}, {"logs", "Fetch the logs of a container"}, {"port", "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"}, - {"proc", "Lookup the running processes of a container"}, + {"top", "Lookup the running processes of a container"}, {"ps", "List containers"}, {"pull", "Pull an image or a repository from the docker registry server"}, {"push", "Push an image or a repository to the docker registry server"}, @@ -556,8 +556,8 @@ func (cli *DockerCli) CmdInspect(args ...string) error { return nil } -func (cli *DockerCli) CmdProc(args ...string) error { - cmd := Subcmd("proc", "CONTAINER", "Lookup the running processes of a container") +func (cli *DockerCli) CmdTop(args ...string) error { + cmd := Subcmd("top", "CONTAINER", "Lookup the running processes of a container") if err := cmd.Parse(args); err != nil { return nil } @@ -565,11 +565,11 @@ func (cli *DockerCli) CmdProc(args ...string) error { cmd.Usage() return nil } - body, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/proc", nil) + body, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/top", nil) if err != nil { return err } - var procs []APIProc + var procs []APITop err = json.Unmarshal(body, &procs) if err != nil { return err diff --git a/docs/sources/api/docker_remote_api.rst b/docs/sources/api/docker_remote_api.rst index f002ac40bc..ea75ada703 100644 --- a/docs/sources/api/docker_remote_api.rst +++ b/docs/sources/api/docker_remote_api.rst @@ -29,7 +29,7 @@ You can still call an old version of the api using /v1.0/images//insert What's new ---------- -Listing processes (/proc): +Listing processes (/top): - List the processes inside a container diff --git a/docs/sources/api/docker_remote_api_v1.3.rst b/docs/sources/api/docker_remote_api_v1.3.rst index 6f7025c449..a56703e6a4 100644 --- a/docs/sources/api/docker_remote_api_v1.3.rst +++ b/docs/sources/api/docker_remote_api_v1.3.rst @@ -223,7 +223,7 @@ Inspect a container List processes running inside a container ***************************************** -.. http:get:: /containers/(id)/proc +.. http:get:: /containers/(id)/top List processes running inside the container ``id`` @@ -231,7 +231,7 @@ List processes running inside a container .. sourcecode:: http - GET /containers/4fa6e0f0c678/proc HTTP/1.1 + GET /containers/4fa6e0f0c678/top HTTP/1.1 **Example response**: diff --git a/docs/sources/commandline/cli.rst b/docs/sources/commandline/cli.rst index 357423fb93..e499b1f096 100644 --- a/docs/sources/commandline/cli.rst +++ b/docs/sources/commandline/cli.rst @@ -41,7 +41,6 @@ Available Commands command/login command/logs command/port - command/proc command/ps command/pull command/push @@ -53,5 +52,6 @@ Available Commands command/start command/stop command/tag + command/top command/version command/wait diff --git a/docs/sources/commandline/command/proc.rst b/docs/sources/commandline/command/top.rst similarity index 58% rename from docs/sources/commandline/command/proc.rst rename to docs/sources/commandline/command/top.rst index b7e9a96ae1..bdd35adcfa 100644 --- a/docs/sources/commandline/command/proc.rst +++ b/docs/sources/commandline/command/top.rst @@ -1,13 +1,13 @@ -:title: Proc Command +:title: Top Command :description: Lookup the running processes of a container -:keywords: proc, docker, container, documentation +:keywords: top, docker, container, documentation ======================================================= -``proc`` -- Lookup the running processes of a container +``top`` -- Lookup the running processes of a container ======================================================= :: - Usage: docker proc CONTAINER + Usage: docker top CONTAINER Lookup the running processes of a container diff --git a/server.go b/server.go index 7d292fc645..b9eba5215b 100644 --- a/server.go +++ b/server.go @@ -249,18 +249,18 @@ func (srv *Server) ImageHistory(name string) ([]APIHistory, error) { } -func (srv *Server) ContainerProc(name string) ([]APIProc, error) { +func (srv *Server) ContainerTop(name string) ([]APITop, error) { if container := srv.runtime.Get(name); container != nil { output, err := exec.Command("lxc-ps", "--name", container.ID).CombinedOutput() if err != nil { return nil, fmt.Errorf("Error trying to use lxc-ps: %s (%s)", err, output) } - var procs []APIProc + var procs []APITop for i, line := range strings.Split(string(output), "\n") { if i == 0 || len(line) == 0 { continue } - proc := APIProc{} + proc := APITop{} scanner := bufio.NewScanner(strings.NewReader(line)) scanner.Split(bufio.ScanWords) if !scanner.Scan() {