2014-08-13 01:46:43 +08:00
|
|
|
package main
|
2014-06-05 07:46:30 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var statsCommand = cli.Command{
|
2015-02-01 12:51:12 +08:00
|
|
|
Name: "stats",
|
|
|
|
Usage: "display statistics for the container",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.StringFlag{Name: "id", Value: "nsinit", Usage: "specify the ID for a container"},
|
|
|
|
},
|
|
|
|
Action: func(context *cli.Context) {
|
|
|
|
container, err := getContainer(context)
|
|
|
|
if err != nil {
|
2015-02-12 09:42:58 +08:00
|
|
|
fatal(err)
|
2015-02-01 12:51:12 +08:00
|
|
|
}
|
|
|
|
stats, err := container.Stats()
|
|
|
|
if err != nil {
|
2015-02-12 09:42:58 +08:00
|
|
|
fatal(err)
|
2015-02-01 12:51:12 +08:00
|
|
|
}
|
2015-02-12 09:42:58 +08:00
|
|
|
data, err := json.MarshalIndent(stats, "", "\t")
|
2015-02-01 12:51:12 +08:00
|
|
|
if err != nil {
|
2015-02-12 09:42:58 +08:00
|
|
|
fatal(err)
|
2015-02-01 12:51:12 +08:00
|
|
|
}
|
|
|
|
fmt.Printf("%s", data)
|
|
|
|
},
|
2014-06-05 07:46:30 +08:00
|
|
|
}
|