Actually close connection everytime through the loop.
Also, only use the client when err != nil (c could be non-nil when err == nil)
This commit is contained in:
parent
9c3a0b21cc
commit
b4b5d5cc95
@ -260,19 +260,18 @@ func main() {
|
||||
c, err := ssh.Dial("tcp", host, config)
|
||||
if err != nil {
|
||||
glog.Errorf("Error dialing %q: %v", host, err)
|
||||
}
|
||||
if c != nil {
|
||||
} else {
|
||||
stats, err := fetchSnapshotStats(host, c)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to update metrics: %v", err)
|
||||
c.Close()
|
||||
c = nil
|
||||
}
|
||||
} else {
|
||||
hss.Lock()
|
||||
hss.host2Stats[host] = stats
|
||||
hss.Unlock()
|
||||
updateMetrics(host, stats)
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
time.Sleep(*refreshInterval)
|
||||
}
|
||||
}(u, h)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user