Set timeout and re-dial on any failures.
This commit is contained in:
parent
a61e9c7e1c
commit
5171c33d3c
@ -151,16 +151,23 @@ func main() {
|
|||||||
Auth: ams,
|
Auth: ams,
|
||||||
// TODO(wathiede); use FixedHostKey?
|
// TODO(wathiede); use FixedHostKey?
|
||||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
}
|
Timeout: 5 * time.Second,
|
||||||
c, err := ssh.Dial("tcp", *host, config)
|
|
||||||
if err != nil {
|
|
||||||
glog.Exitf("Error dialing %q: %v", *host, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
var c *ssh.Client
|
||||||
|
if c == nil {
|
||||||
|
var err error
|
||||||
|
c, err = ssh.Dial("tcp", *host, config)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Error dialing %q: %v", *host, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err := updateMetrics(c); err != nil {
|
if err := updateMetrics(c); err != nil {
|
||||||
glog.Errorf("Failed to update metrics: %v", err)
|
glog.Errorf("Failed to update metrics: %v", err)
|
||||||
|
c.Close()
|
||||||
|
c = nil
|
||||||
}
|
}
|
||||||
time.Sleep(*refreshInterval)
|
time.Sleep(*refreshInterval)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user