diff options
author | Saku Ytti <saku@ytti.fi> | 2014-03-02 13:11:51 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-03-02 13:11:51 +0200 |
commit | f7ba5b70aa0222e4f4c75696fbd487a6b0d4e703 (patch) | |
tree | 188f91d28c11f83fa2598667d195d73dd6743f25 | |
parent | 4baedb0667185fb899ad1c1f5a7782d1228807a9 (diff) |
Give up after timeout on SSH#expect
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | lib/oxidized/input/ssh.rb | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 3003aa8..1dd5c2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - oxidized (0.0.33) + oxidized (0.0.34) grit haml net-ssh diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index 24401dd..a0a5916 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -1,5 +1,6 @@ module Oxidized require 'net/ssh' + require 'timeout' require 'oxidized/input/cli' class SSH < Input RescueFail = { @@ -83,9 +84,11 @@ module Oxidized end def expect regexp - @ssh.loop(0.1) do - sleep 0.1 - not @output.match regexp + Timeout::timeout(CFG.timeout) do + @ssh.loop(0.1) do + sleep 0.1 + not @output.match regexp + end end end |