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
It's copy-paste from CmdInspect. I've marked both functions with TODO (will
extract common things and make their code less ugly).

Thanks for the tip, just a first week with Go :)
On Fri 31 Oct 2014 at 10:22 pm Erik Hollensbe <notifications@github.com>
wrote:

> In api/client/commands.go:
>
> > @@ -812,6 +812,46 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
> >  	return nil
> >  }
> >
> > +func (cli *DockerCli) CmdMetrics(args ...string) error {
> > +	cmd := cli.Subcmd("metrics", "CONTAINER", "Return runtime information on a container")
> > +	if err := cmd.Parse(args); err != nil {
> > +		return nil
> > +	}
> > +	if cmd.NArg() < 1 {
> > +		cmd.Usage()
> > +		return nil
> > +	}
> > +
> > +	indented := new(bytes.Buffer)
>
> use json.Unmarshal and a struct or map for this, please.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/docker/docker/pull/8886/files#r19688050>.
>