cfha/main.go

39 lines
676 B
Go
Raw Normal View History

2015-08-21 17:27:26 +00:00
package main
import (
"log"
"fmt"
"io/ioutil"
"encoding/json"
"./monitor"
)
func main() {
file, err := ioutil.ReadFile("./config.json")
if err != nil {
log.Fatal(fmt.Sprintf("%v\n", err))
}
c := monitor.Config{}
json.Unmarshal(file, &c)
for _, check := range c.Checks {
handlers := make([]*monitor.GenericHandler, 0)
2015-08-21 17:27:26 +00:00
for _, reaction := range check.Reactions {
handler := monitor.CreateHandler(reaction)
2015-08-21 17:27:26 +00:00
if handler == nil {
continue
}
handlers = append(handlers, handler)
}
engine := monitor.CreateEngine(handlers)
monitor.CreateCheck(check.Interval, engine, check.Target)
2015-08-21 17:27:26 +00:00
}
select{}
}