Implement container stats collection in daemon
Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Upstream-commit: 65f58e2a742205c9e8470b360bd439642a5c8211 Component: engine
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/daemon/execdriver"
|
||||
@ -279,6 +280,23 @@ func (d *driver) Clean(id string) error {
|
||||
return os.RemoveAll(filepath.Join(d.root, id))
|
||||
}
|
||||
|
||||
func (d *driver) Stats(id string) (*execdriver.ResourceStats, error) {
|
||||
state, err := libcontainer.GetState(filepath.Join(d.root, id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
now := time.Now()
|
||||
stats, err := libcontainer.GetStats(nil, state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &execdriver.ResourceStats{
|
||||
ContainerStats: stats,
|
||||
ClockTicks: system.GetClockTicks(),
|
||||
Read: now,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getEnv(key string, env []string) string {
|
||||
for _, pair := range env {
|
||||
parts := strings.Split(pair, "=")
|
||||
|
||||
Reference in New Issue
Block a user