Tables are now updated only if status of host changers
This commit is contained in:
parent
b869e7442a
commit
a5a5854276
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue