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) {
|
func checkGroup(name string, group Group, waitGroup *sync.WaitGroup, stopChannel chan bool) {
|
||||||
channels := make(map[string]chan int)
|
channels := make(map[string]chan int)
|
||||||
|
statusPerHost := make(map[string]int)
|
||||||
for _, host := range group.Hosts {
|
for _, host := range group.Hosts {
|
||||||
channel := make(chan int, 1)
|
channel := make(chan int, 1)
|
||||||
channels[host] = channel
|
channels[host] = channel
|
||||||
|
statusPerHost[host] = -1
|
||||||
waitGroup.Add(1)
|
waitGroup.Add(1)
|
||||||
go checkHost(channels[host], name, host, group.Check, waitGroup, stopChannel)
|
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
|
break
|
||||||
case status := <-channel:
|
case status := <-channel:
|
||||||
if verbose > 1 {
|
if verbose > 1 {
|
||||||
|
log.Println("Status for ", host, "was", statusPerHost[host], "in group", name)
|
||||||
log.Println("Status for ", host, "is", status, "in group", name)
|
log.Println("Status for ", host, "is", status, "in group", name)
|
||||||
}
|
}
|
||||||
|
if statusPerHost[host] == -1 || statusPerHost[host] != status {
|
||||||
|
statusPerHost[host] = status
|
||||||
updateTables(host, status, group.Tables)
|
updateTables(host, status, group.Tables)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue