runc/nsinit/stats.go

33 lines
615 B
Go

package main
import (
"encoding/json"
"fmt"
"log"
"github.com/codegangsta/cli"
)
var statsCommand = cli.Command{
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 {
log.Fatal(err)
}
stats, err := container.Stats()
if err != nil {
log.Fatal(err)
}
data, jerr := json.MarshalIndent(stats, "", "\t")
if err != nil {
log.Fatal(jerr)
}
fmt.Printf("%s", data)
},
}