-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
71 lines (61 loc) · 1.43 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"github.com/burntsushi/toml"
"github.com/kr/pretty"
"github.com/protip/cw-engine/cwengine"
)
type Config struct {
GraphiteHost string
GraphitePort int
GraphiteBuffer int
StatsInterval int
StatsKeyPrefix string
Accounts []Account
}
type Account struct {
AwsAccessKey string
AwsSecretKey string
Templates []Template
}
type Template struct {
cwengine.CloudWatchMetric
DimensionList [][]string
}
var (
conf Config
cwMonMon *cwengine.MonMon
resultC chan *cwengine.MonResult
)
func init() {
if _, err := toml.DecodeFile("config.toml", &conf); err != nil {
panic(err)
}
cwMonMon = cwengine.NewMonMon()
resultC = make(chan *cwengine.MonResult, 100000)
cwMonMon.ResultsToGraphite(resultC, conf.GraphiteHost, conf.GraphitePort, conf.GraphiteBuffer)
cwMonMon.StatsInterval = conf.StatsInterval
cwMonMon.StatsKeyPrefix = conf.StatsKeyPrefix
}
func main() {
fmt.Println("Hello World!!!!!")
pretty.Print(conf)
PrimeEngine()
select {}
}
func PrimeEngine() {
for _, account := range conf.Accounts {
ProcessAccount(account)
}
}
func ProcessAccount(account Account) {
for _, template := range account.Templates {
template.AwsKey = account.AwsAccessKey
template.AwsSecret = account.AwsSecretKey
ProcessTemplate(template)
}
}
func ProcessTemplate(template Template) {
template.SetDimensions(template.DimensionList)
cwMonMon.MonitorAllFoundFor(&template.CloudWatchMetric, resultC)
}