Skip to content

Commit

Permalink
Merge pull request #26 from masaruhoshi/handle-new-monitor
Browse files Browse the repository at this point in the history
Handle newly added monitor
  • Loading branch information
felipesantiago authored May 28, 2018
2 parents 8dec5b8 + aa6dc92 commit 7d46558
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions collector/uptimerobot.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ 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)
continue
}
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
}
Expand Down

0 comments on commit 7d46558

Please sign in to comment.