Implement container stats collection in daemon

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 65f58e2a742205c9e8470b360bd439642a5c8211
Component: engine
This commit is contained in:
Michael Crosby
2015-01-07 14:43:04 -08:00
parent ff8b2a1301
commit 947efff180
8 changed files with 155 additions and 0 deletions

View File

@ -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, "=")