diff options
author | Chong Cai <chongc@google.com> | 2021-08-13 14:17:56 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-13 14:20:12 -0700 |
commit | 6eb8596f72f3c889de3f826b82319d41ac655829 (patch) | |
tree | 6dcae39e3fbb4bdf078dd5d77e19ef5626712d8d /runsc/cmd | |
parent | a7b59445db6b76611ea384659cff8f0dfa75cb00 (diff) |
Add Event controls
Add Event controls and implement "stream" commands.
PiperOrigin-RevId: 390691702
Diffstat (limited to 'runsc/cmd')
-rw-r--r-- | runsc/cmd/events.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/runsc/cmd/events.go b/runsc/cmd/events.go index c1d029d7f..08246e543 100644 --- a/runsc/cmd/events.go +++ b/runsc/cmd/events.go @@ -33,6 +33,10 @@ type Events struct { intervalSec int // If true, events will print a single group of stats and exit. stats bool + // If true, events will dump all filtered events to stdout. + stream bool + // filters for streamed events. + filters stringSlice } // Name implements subcommands.Command.Name. @@ -62,6 +66,8 @@ OPTIONS: func (evs *Events) SetFlags(f *flag.FlagSet) { f.IntVar(&evs.intervalSec, "interval", 5, "set the stats collection interval, in seconds") f.BoolVar(&evs.stats, "stats", false, "display the container's stats then exit") + f.BoolVar(&evs.stream, "stream", false, "dump all filtered events to stdout") + f.Var(&evs.filters, "filters", "only display matching events") } // Execute implements subcommands.Command.Execute. @@ -79,6 +85,13 @@ func (evs *Events) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa Fatalf("loading sandbox: %v", err) } + if evs.stream { + if err := c.Stream(evs.filters, os.Stdout); err != nil { + Fatalf("Stream failed: %v", err) + } + return subcommands.ExitSuccess + } + // Repeatedly get stats from the container. for { // Get the event and print it as JSON. |