From aa6dc923a5fb2c3f99ada13419cb58c61e5a343b Mon Sep 17 00:00:00 2001 From: Masaru Hoshi Date: Mon, 28 May 2018 11:31:56 -0400 Subject: [PATCH] Handle newly added monitor --- collector/uptimerobot.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/collector/uptimerobot.go b/collector/uptimerobot.go index ccc9546..2f8b902 100644 --- a/collector/uptimerobot.go +++ b/collector/uptimerobot.go @@ -57,6 +57,8 @@ func ScrapeUptimeRobot(client *api.Client, ch chan<- prometheus.Metric) error { totalMonitors = xmlMonitors.Pagination.Total for _, monitor := range xmlMonitors.Monitors { up := 1.0 + status := 0.0 + responseTime := 0.0 if scappedMonitors[monitor.ID] { log.Warnf("Trying to scrape a duplicate monitor for %s", monitor.FriendlyName) @@ -64,10 +66,10 @@ func ScrapeUptimeRobot(client *api.Client, ch chan<- prometheus.Metric) error { } if monitor.ResponseTimes == nil { log.Warnf("No response times collected for %s", monitor.FriendlyName) - continue + } else { + status, _ = strconv.ParseFloat(monitor.Status, 64) + responseTime = float64(monitor.ResponseTimes[0].Value) } - status, _ := strconv.ParseFloat(monitor.Status, 64) - responseTime := float64(monitor.ResponseTimes[0].Value) if status != statusUp { up = 0 }