diff --git a/hostchecker.go b/hostchecker.go index 3ccbf5a..ff1a244 100644 --- a/hostchecker.go +++ b/hostchecker.go @@ -108,9 +108,11 @@ func main() { func checkGroup(name string, group Group, waitGroup *sync.WaitGroup, stopChannel chan bool) { channels := make(map[string]chan int) + statusPerHost := make(map[string]int) for _, host := range group.Hosts { channel := make(chan int, 1) channels[host] = channel + statusPerHost[host] = -1 waitGroup.Add(1) go checkHost(channels[host], name, host, group.Check, waitGroup, stopChannel) } @@ -133,9 +135,13 @@ func checkGroup(name string, group Group, waitGroup *sync.WaitGroup, stopChannel break case status := <-channel: if verbose > 1 { + log.Println("Status for ", host, "was", statusPerHost[host], "in group", name) log.Println("Status for ", host, "is", status, "in group", name) } - updateTables(host, status, group.Tables) + if statusPerHost[host] == -1 || statusPerHost[host] != status { + statusPerHost[host] = status + updateTables(host, status, group.Tables) + } default: time.Sleep(100 * time.Millisecond) }