|
@@ -2,20 +2,20 @@ package daemon
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "io"
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
|
- "github.com/docker/docker/engine"
|
|
|
"github.com/docker/libcontainer"
|
|
|
"github.com/docker/libcontainer/cgroups"
|
|
|
)
|
|
|
|
|
|
-func (daemon *Daemon) ContainerStats(job *engine.Job) error {
|
|
|
- updates, err := daemon.SubscribeToContainerStats(job.Args[0])
|
|
|
+func (daemon *Daemon) ContainerStats(name string, out io.Writer) error {
|
|
|
+ updates, err := daemon.SubscribeToContainerStats(name)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- enc := json.NewEncoder(job.Stdout)
|
|
|
+ enc := json.NewEncoder(out)
|
|
|
for v := range updates {
|
|
|
update := v.(*execdriver.ResourceStats)
|
|
|
ss := convertToAPITypes(update.Stats)
|
|
@@ -24,7 +24,7 @@ func (daemon *Daemon) ContainerStats(job *engine.Job) error {
|
|
|
ss.CpuStats.SystemUsage = update.SystemUsage
|
|
|
if err := enc.Encode(ss); err != nil {
|
|
|
// TODO: handle the specific broken pipe
|
|
|
- daemon.UnsubscribeToContainerStats(job.Args[0], updates)
|
|
|
+ daemon.UnsubscribeToContainerStats(name, updates)
|
|
|
return err
|
|
|
}
|
|
|
}
|