mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-12 09:46:25 +08:00
28dadc538c
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
40 lines
653 B
Go
40 lines
653 B
Go
package nsinit
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/codegangsta/cli"
|
|
"github.com/docker/libcontainer"
|
|
)
|
|
|
|
var statsCommand = cli.Command{
|
|
Name: "stats",
|
|
Usage: "display statistics for the container",
|
|
Action: statsAction,
|
|
}
|
|
|
|
func statsAction(context *cli.Context) {
|
|
container, err := loadContainer()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
state, err := libcontainer.GetState(dataPath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
stats, err := libcontainer.GetStats(container, state)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
data, err := json.MarshalIndent(stats, "", "\t")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fmt.Printf("%s", data)
|
|
}
|