bugfix badword and change detection
This commit is contained in:
parent
80ad9d9dc3
commit
e3de4a2ef6
11
watchdog.go
11
watchdog.go
|
@ -70,6 +70,8 @@ func (d *Dog) Watch() {
|
|||
}
|
||||
}
|
||||
|
||||
// Now that I've added the ability to notify when a server is back up
|
||||
// this definitely needs some refactoring. It's bad now.
|
||||
func (d *Dog) watch() {
|
||||
d.Logger <- fmt.Sprintf("Check: '%s'", d.Name)
|
||||
|
||||
|
@ -88,6 +90,7 @@ func (d *Dog) watch() {
|
|||
if nil != err2 {
|
||||
d.Logger <- fmt.Sprintf("Down: '%s': %s", d.Name, err2)
|
||||
} else {
|
||||
d.notify("hiccuped")
|
||||
d.Logger <- fmt.Sprintf("Hiccup: '%s': %s", d.Name, err)
|
||||
return
|
||||
}
|
||||
|
@ -109,11 +112,13 @@ func (d *Dog) watch() {
|
|||
// TODO what if the server is flip-flopping rapidly?
|
||||
// how to rate limit?
|
||||
// "{{ .Server }} is on cooldown for 30 minutes"
|
||||
if changed {
|
||||
if changed || d.changed {
|
||||
changed = false
|
||||
d.notify("went down")
|
||||
if StatusUp == d.status {
|
||||
d.notify("came back up")
|
||||
break
|
||||
} else {
|
||||
d.notify("went down")
|
||||
}
|
||||
|
||||
// * We've had success since the last notification
|
||||
|
@ -176,7 +181,7 @@ func (d *Dog) check() error {
|
|||
}
|
||||
|
||||
if "" != d.Badwords {
|
||||
if !bytes.Contains(b, []byte(d.Badwords)) {
|
||||
if bytes.Contains(b, []byte(d.Badwords)) {
|
||||
err = fmt.Errorf("Down: '%s' Found for '%s'", d.Badwords, d.Name)
|
||||
d.Logger <- fmt.Sprintf("%s", err)
|
||||
d.error = err
|
||||
|
|
Loading…
Reference in New Issue