From f7ba5b70aa0222e4f4c75696fbd487a6b0d4e703 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sun, 2 Mar 2014 13:11:51 +0200 Subject: Give up after timeout on SSH#expect --- lib/oxidized/input/ssh.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') 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 -- cgit v1.2.1