mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Filter events
This commit is contained in:
parent
cfa43f809e
commit
d98ce102b1
@ -78,18 +78,15 @@ func (cm *Docker) Wait() struct{} { return <-cm.closed }
|
|||||||
func (cm *Docker) watchEvents() {
|
func (cm *Docker) watchEvents() {
|
||||||
log.Info("docker event listener starting")
|
log.Info("docker event listener starting")
|
||||||
events := make(chan *api.APIEvents)
|
events := make(chan *api.APIEvents)
|
||||||
cm.client.AddEventListener(events)
|
opts := api.EventsOptions{Filters: map[string][]string{
|
||||||
|
"type": {"container"},
|
||||||
|
"event": {"create", "start", "health_status", "pause", "unpause", "stop", "die", "destroy"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
cm.client.AddEventListenerWithOptions(opts, events)
|
||||||
|
|
||||||
for e := range events {
|
for e := range events {
|
||||||
if e.Type != "container" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
actionName := e.Action
|
actionName := e.Action
|
||||||
// fast skip all exec_* events: exec_create, exec_start, exec_die
|
|
||||||
if strings.HasPrefix(actionName, "exec_") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Action may have additional param i.e. "health_status: healthy"
|
// Action may have additional param i.e. "health_status: healthy"
|
||||||
// We need to strip to have only action name
|
// We need to strip to have only action name
|
||||||
sepIdx := strings.Index(actionName, ": ")
|
sepIdx := strings.Index(actionName, ": ")
|
||||||
|
Loading…
Reference in New Issue
Block a user