Just output raw stats json
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
This commit is contained in:
parent
21b71ef33d
commit
361ac10612
|
@ -21,30 +21,19 @@ func statsAction(context *cli.Context) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
runtimeCkpt, err := libcontainer.GetState(dataPath)
|
||||
state, err := libcontainer.GetState(dataPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
stats, err := getStats(container, runtimeCkpt)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get stats - %v\n", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Stats:\n%v\n", stats)
|
||||
}
|
||||
|
||||
// returns the container stats in json format.
|
||||
func getStats(container *libcontainer.Config, state *libcontainer.State) (string, error) {
|
||||
stats, err := libcontainer.GetStats(container, state)
|
||||
if err != nil {
|
||||
return "", err
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
out, err := json.MarshalIndent(stats, "", "\t")
|
||||
data, err := json.MarshalIndent(stats, "", "\t")
|
||||
if err != nil {
|
||||
return "", err
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return string(out), nil
|
||||
fmt.Printf("%s", data)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue