forked from gerty-monit/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (45 loc) · 1.4 KB
/
main.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
53
package main
import (
"fmt"
core "github.com/gerty-monit/core"
"log"
)
func tcpMonitors() []core.Monitor {
google := core.NewTcpMonitor("Google IP A", "Try to connect to Google port 80", "181.15.96.152", 80)
google2 := core.NewTcpMonitor("Google IP B", "Try to connect to Google port 80", "172.217.29.3", 80)
return []core.Monitor{google, google2}
}
func main() {
port := 8080
server := core.GertyServer{}
facebook := core.NewHttpMonitor("Facebook Home", "Try to reach facebook home via Http", "http://www.facebook.com")
server.Groups = []core.Group{
core.Group{Name: "Network", Monitors: tcpMonitors()},
core.Group{Name: "Http", Monitors: []core.Monitor{facebook}},
}
yourSlackHook := "https://hooks.slack.com/services/FOO/BAR/BAZ"
slackAlarm := core.NewSlackAlarm(yourSlackHook)
fromAddress := "[email protected]"
toAddress := "[email protected]"
awsSmtpUser := "AWS_EMAIL_USER"
awsSmtpPass := "AWS_EMAIL_PASS"
dashboardHome := "https://alarms.example.com"
emailAlarm := core.NewEmailAlarm(
"email-smtp.us-east-1.amazonaws.com",
"587",
awsSmtpUser,
awsSmtpPass,
fromAddress,
toAddress,
dashboardHome,
)
log.Printf("alarms %s and %s disabled, uncomment below to activate",
slackAlarm.Name(),
emailAlarm.Name())
// server.Alarms = []a.Alarm{
// slackAlarm,
// emailAlarm,
// }
log.Printf("server started on port %d", port)
server.ListenAndServe(fmt.Sprintf(":%d", port))
}