Skip to content

Commit

Permalink
Improves reminders to prevent extra alerts after outage (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
fusiondog committed Apr 29, 2016
1 parent 9b91505 commit 9e5e250
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions check-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"time"
"math"

"net/http"

Expand Down Expand Up @@ -57,12 +58,11 @@ func (c *CheckProcessor) reminderRun() {
messages := consulClient.GetReminders()
filteredMessages := make(notifier.Messages, 0)
for _, message := range messages {
duration := time.Since(message.Timestamp)
durMins := int(duration.Minutes())
duration := time.Since(message.RmdCheck)
durMins := int(math.Ceil(duration.Minutes()))
log.Println("Reminder message duration minutes: ", durMins)
totalInterval := message.IntCount * message.Interval
if durMins >= totalInterval {
message.IntCount++
if durMins >= message.Interval {
message.RmdCheck=time.Now()
consulClient.SetReminder(message)
filteredMessages = append(filteredMessages, message)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (c *CheckProcessor) notify(alerts []consul.Check) {
Output: alert.Output,
Notes: alert.Notes,
Interval: interval,
IntCount: 1,
RmdCheck: time.Now(),
NotifList: notifMap,
Timestamp: time.Now(),
}
Expand Down
2 changes: 1 addition & 1 deletion notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Message struct {
Output string
Notes string
Interval int
IntCount int
RmdCheck time.Time
NotifList map[string]bool
Timestamp time.Time
}
Expand Down

0 comments on commit 9e5e250

Please sign in to comment.