mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Windows: Minimal docker top implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
@@ -1,12 +1,32 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/docker/engine-api/types"
|
||||
)
|
||||
|
||||
// ContainerTop is not supported on Windows and returns an error.
|
||||
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) {
|
||||
return nil, fmt.Errorf("Top is not supported on Windows")
|
||||
// ContainerTop is a minimal implementation on Windows currently.
|
||||
// TODO Windows: This needs more work, but needs platform API support.
|
||||
// All we can currently return (particularly in the case of Hyper-V containers)
|
||||
// is a PID and the command.
|
||||
func (daemon *Daemon) ContainerTop(containerID string, psArgs string) (*types.ContainerProcessList, error) {
|
||||
|
||||
// It's really not an equivalent to linux 'ps' on Windows
|
||||
if psArgs != "" {
|
||||
return nil, errors.New("Windows does not support arguments to top")
|
||||
}
|
||||
|
||||
s, err := daemon.containerd.Summary(containerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
procList := &types.ContainerProcessList{}
|
||||
|
||||
for _, v := range s {
|
||||
procList.Titles = append(procList.Titles, strconv.Itoa(int(v.Pid))+" "+v.Command)
|
||||
}
|
||||
return procList, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user