Add nsinit command to display oom notifications
This adds the ability to receive OOM notifications for a container via the `nsinit oom` command. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
9377591781
commit
4bbd44784c
|
@ -53,11 +53,12 @@ func main() {
|
|||
app.Before = preload
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
configCommand,
|
||||
execCommand,
|
||||
initCommand,
|
||||
statsCommand,
|
||||
configCommand,
|
||||
oomCommand,
|
||||
pauseCommand,
|
||||
statsCommand,
|
||||
unpauseCommand,
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue