From 5c4f0c2e69f793ce1c6cf73695036fc1f7ab0385 Mon Sep 17 00:00:00 2001 From: Matej Kramny Date: Thu, 19 May 2016 19:34:36 +0100 Subject: [PATCH] Print descriptions from cli --- cli/main.go | 16 ++++++++++++++++ monitor.go | 17 ----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cli/main.go b/cli/main.go index 4028b4d..3a03906 100644 --- a/cli/main.go +++ b/cli/main.go @@ -53,6 +53,22 @@ func main() { wg := &sync.WaitGroup{} for _, mon := range cfg.Monitors { + cfg.Logger.Printf(" Starting %s: %d seconds check interval\n - %v %s", mon.Name, mon.CheckInterval, mon.Method, mon.URL) + + // print features + if mon.ExpectedStatusCode > 0 { + cfg.Logger.Printf(" - Expect HTTP %d", mon.ExpectedStatusCode) + } + if len(mon.ExpectedBody) > 0 { + cfg.Logger.Printf(" - Expect Body to match \"%v\"", mon.ExpectedBody) + } + if mon.MetricID > 0 { + cfg.Logger.Printf(" - Log lag to metric id %d\n", mon.MetricID) + } + if mon.ComponentID > 0 { + cfg.Logger.Printf(" - Update component id %d\n\n", mon.ComponentID) + } + go mon.Start(cfg, wg) } diff --git a/monitor.go b/monitor.go index fbe7927..d28d6f4 100644 --- a/monitor.go +++ b/monitor.go @@ -48,23 +48,6 @@ func (mon *Monitor) Start(cfg *CachetMonitor, wg *sync.WaitGroup) { wg.Add(1) mon.config = cfg mon.stopC = make(chan bool) - - mon.config.Logger.Printf(" Starting %s: %d seconds check interval\n - %v %s", mon.Name, mon.CheckInterval, mon.Method, mon.URL) - - // print features - if mon.ExpectedStatusCode > 0 { - mon.config.Logger.Printf(" - Expect HTTP %d", mon.ExpectedStatusCode) - } - if len(mon.ExpectedBody) > 0 { - mon.config.Logger.Printf(" - Expect Body to match \"%v\"", mon.ExpectedBody) - } - if mon.MetricID > 0 { - mon.config.Logger.Printf(" - Log lag to metric id %d\n", mon.MetricID) - } - if mon.ComponentID > 0 { - mon.config.Logger.Printf(" - Update component id %d\n\n", mon.ComponentID) - } - mon.Tick() ticker := time.NewTicker(mon.CheckInterval * time.Second)