|
7 | 7 | "github.com/bcicen/ctop/connector/manager"
|
8 | 8 | "github.com/bcicen/ctop/container"
|
9 | 9 | "github.com/docker/docker/api/types"
|
| 10 | + "github.com/docker/docker/api/types/filters" |
10 | 11 | "github.com/docker/docker/api/types/network"
|
11 | 12 | "github.com/docker/docker/client"
|
12 | 13 | "github.com/docker/go-connections/nat"
|
@@ -83,20 +84,22 @@ func (cm *Docker) Wait() struct{} { return <-cm.closed }
|
83 | 84 | func (cm *Docker) watchEvents() {
|
84 | 85 | log.Info("docker event listener starting")
|
85 | 86 | ctx := context.Background()
|
86 |
| - |
87 |
| - eventsOpts := types.EventsOptions{} |
| 87 | + filter := filters.NewArgs() |
| 88 | + filter.Add("type", "container") |
| 89 | + filter.Add("event", "health_status") |
| 90 | + filter.Add("event", "create") |
| 91 | + filter.Add("event", "destroy") |
| 92 | + filter.Add("event", "start") |
| 93 | + filter.Add("event", "die") |
| 94 | + filter.Add("event", "stop") |
| 95 | + filter.Add("event", "pause") |
| 96 | + filter.Add("event", "unpause") |
| 97 | + |
| 98 | + eventsOpts := types.EventsOptions{Filters: filter} |
88 | 99 | events, _ := cm.client.Events(ctx, eventsOpts)
|
89 | 100 |
|
90 | 101 | for e := range events {
|
91 |
| - if e.Type != "container" { |
92 |
| - continue |
93 |
| - } |
94 |
| - |
95 | 102 | actionName := e.Action
|
96 |
| - // fast skip all exec_* events: exec_create, exec_start, exec_die |
97 |
| - if strings.HasPrefix(actionName, "exec_") { |
98 |
| - continue |
99 |
| - } |
100 | 103 | // Action may have additional param i.e. "health_status: healthy"
|
101 | 104 | // We need to strip to have only action name
|
102 | 105 | sepIdx := strings.Index(actionName, ": ")
|
|
0 commit comments