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
As I understand we need to implement websocket endpoint. I think I can make
it in my branch.

Also we need to add customizable interval option with reasonable default
value (1s for example).

Do we need to have template formatter to receive partial data?

Maybe we also need to have special predefined formatters to output metrics
(pretty output for humans by default and, machine readable JSON for
scripts)?

Are there any public spec for this feature?
On Sat 1 Nov 2014 at 1:05 am Michael Crosby <notifications@github.com>
wrote:

> In api/server/server.go:
>
> > @@ -1262,6 +1275,7 @@ func createRouter(eng *engine.Engine, logging, enableCors bool, dockerVersion st
> >  			"/containers/{name:.*}/top":       getContainersTop,
> >  			"/containers/{name:.*}/logs":      getContainersLogs,
> >  			"/containers/{name:.*}/attach/ws": wsContainersAttach,
> > +			"/containers/{name:.*}/metrics":   getContainersMetrics,
>
> You are correct. We want a push approach where a client will subscribe to
> an docker endpoint and metrics will be pushed to the consumer with a
> requested internal
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/docker/docker/pull/8886/files#r19696346>.
>