2015-01-27 20:54:19 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var oomCommand = cli.Command{
|
2015-02-01 12:51:12 +08:00
|
|
|
Name: "oom",
|
|
|
|
Usage: "display oom notifications for a 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)
|
|
|
|
}
|
2015-02-12 07:09:54 +08:00
|
|
|
n, err := container.NotifyOOM()
|
2015-02-01 12:51:12 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2015-02-13 04:58:40 +08:00
|
|
|
for x := range n {
|
|
|
|
// hack for calm down go1.4 gofmt
|
|
|
|
_ = x
|
2015-02-01 12:51:12 +08:00
|
|
|
log.Printf("OOM notification received")
|
|
|
|
}
|
|
|
|
},
|
2015-01-27 20:54:19 +08:00
|
|
|
}
|