-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelastsec.go
43 lines (38 loc) · 1.1 KB
/
elastsec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"./internal/beats/auth"
"./internal/beats/file_integrity"
"./internal/beats/filechange_attempt"
"./internal/event"
"./internal/notify"
"./internal/infoexport"
"./internal/aggregator"
"./internal/env"
)
func main() {
eventBus := make(chan event.Event)
aggregatedEventBus := make(chan event.Event)
var a aggregator.Aggregator
a.SupressedCount = make(map[aggregator.Key]*aggregator.Info)
go auth.Loop(eventBus)
go file_integrity.Loop(eventBus)
go filechange_attempt.Loop(eventBus)
go a.Loop(eventBus, env.GetAggDuration())
go func() {
for event := range eventBus {
event, ok := a.Consume(event)
if ok {
aggregatedEventBus <- event
}
}
}()
email := notify.EmailInit(aggregatedEventBus, env.GetEmailDuration())
go email.Loop()
for event := range aggregatedEventBus {
title := infoexport.GetTitle(event)
fmt.Printf("%s %s\n\n",title,event.Message)
notify.SendSlack(event,title)
email.Consume(event,title)
}
}