better packaging

- update readme
This commit is contained in:
Matej Kramny
2016-05-18 23:54:55 +01:00
parent 025d0c5822
commit 267a6cb6b3
10 changed files with 52 additions and 83 deletions

31
cli/main.go Normal file
View File

@@ -0,0 +1,31 @@
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()
}
}
}