Files
cachet-monitor/cli/main.go
Matej Kramny 267a6cb6b3 better packaging
- update readme
2016-05-18 23:54:55 +01:00

32 lines
731 B
Go

package main
import (
"time"
cachet "github.com/castawaylabs/cachet-monitor"
)
func main() {
cachet.New()
config := cachet.Config
log := cachet.Logger
log.Printf("System: %s, Interval: %d second(s), API: %s\n", config.SystemName, config.Interval, config.APIUrl)
log.Printf("Starting %d monitors:\n", len(config.Monitors))
for _, mon := range config.Monitors {
log.Printf(" %s: GET %s & Expect HTTP %d\n", mon.Name, mon.URL, mon.ExpectedStatusCode)
if mon.MetricID > 0 {
log.Printf(" - Logs lag to metric id: %d\n", mon.MetricID)
}
}
log.Println()
ticker := time.NewTicker(time.Duration(config.Interval) * time.Second)
for range ticker.C {
for _, mon := range config.Monitors {
go mon.Run()
}
}
}