-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmega_timer.go
52 lines (47 loc) · 1.02 KB
/
mega_timer.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
44
45
46
47
48
49
50
51
52
package main
import (
"log"
"time"
)
func MegaTimer(ticker *time.Ticker) {
for t := range ticker.C {
log.Println(BeatAt, t)
go Pulse()
go k8sMonitor()
}
}
func Pulse() {
if Config.Servers != nil {
for servIndex, server := range Config.Servers {
if server.Live {
if Worker.Host != "" {
go DispatchtoWorker(server)
} else {
go Process(server, servIndex)
}
}
}
}
}
func k8sMonitor() {
ShouldLock()
tempCopy := Config.KubeSettings
tempContacts := Config.Contacts
tempTwConfig := Config.SMS
tempMailConfig := Config.Mail
ShouldRequest := Config.KubeSettings.MetricAPIHost != "" && Config.KubeSettings.MetricAPIPath != "" && Config.KubeSettings.MetricAPIPort != ""
ShouldUnlock()
if ShouldRequest {
list, err := RequestPods()
if err != nil {
log.Println(err)
} else {
if tempCopy.Monitoring != nil {
for _, pod := range tempCopy.Monitoring {
// Check and alert contacts
go list.CheckContainers(pod, tempContacts, tempMailConfig, tempTwConfig)
}
}
}
}
}