docker metrics (read metrics from cgroups for specified container)

Fixes #8842.

This is first and very simple implementation of docker metrics command. A lot of work needed to push it to production.

Roadmap:

* make find of cgroup paths more reliable (not just try to search predefined locations, but get exact value from procfs)
* specify set of metrics (from `cpuacct`, `memory`, `blkio`, ... controllers)
* store metrics in `struct` instead of `map[string]string` (typed data)
* `-f FORMAT` support
* documentation

PS. PR created for further discussion and this branch will be constantly updated.

/cc @shykes @tobegit3hub @thaJeztah
There is quite a bit of code in libcontainer to handle stats. I don't see a
point in replicating it. Wouldn't 'lxc-info' work for the lxc driver?

On Mon, Nov 3, 2014 at 2:03 PM, Gleb M Borisov <notifications@github.com>
wrote:

> In daemon/metrics.go:
>
> > +func (daemon *Daemon) ContainerMetrics(job *engine.Job) engine.Status {
> > +	if len(job.Args) != 1 {
> > +		return job.Errorf("usage: %s NAME", job.Name)
> > +	}
> > +	name := job.Args[0]
> > +	if container := daemon.Get(name); container != nil {
> > +		container.Lock()
> > +		defer container.Unlock()
> > +
> > +		out := &engine.Env{}
> > +		out.Set("Id", container.ID)
> > +		out.Set("Image", container.Image)
> > +		out.Set("Name", container.Name)
> > +		out.SetJson("State", container.State)
> > +
> > +		metrics := map[string]string{}
>
> libcontainer's stats is limited only to native driver. Fetching metrics
> directly from cgroups is more portable. I think I need to move this code to
> drivers.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/docker/docker/pull/8886/files#r19770078>.
>