Merge pull request #329 from crosbymichael/oom-nsinit

Add nsinit command to display oom notifications
This commit is contained in:
Victor Marmol 2015-01-12 16:39:16 -08:00
commit dd6bc28afb
2 changed files with 31 additions and 2 deletions

View File

@ -53,11 +53,12 @@ func main() {
app.Before = preload
app.Commands = []cli.Command{
configCommand,
execCommand,
initCommand,
statsCommand,
configCommand,
oomCommand,
pauseCommand,
statsCommand,
unpauseCommand,
}

28
nsinit/oom.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"log"
"github.com/codegangsta/cli"
"github.com/docker/libcontainer"
)
var oomCommand = cli.Command{
Name: "oom",
Usage: "display oom notifications for a container",
Action: oomAction,
}
func oomAction(context *cli.Context) {
state, err := libcontainer.GetState(dataPath)
if err != nil {
log.Fatal(err)
}
n, err := libcontainer.NotifyOnOOM(state)
if err != nil {
log.Fatal(err)
}
for _ = range n {
log.Printf("OOM notification received")
}
}