summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2013-04-27 12:16:55 +0300
committerSaku Ytti <saku@ytti.fi>2013-04-27 12:16:55 +0300
commit70cb33c214ced1235b8e6077e11177a3ba6b7977 (patch)
tree20d0add3984642be00c1685ac0e19e50e2e4288c /lib
parent5fca52c86b50dd9754546902530530b9c0f6216b (diff)
Fix timeout on receiving command from input
Diffstat (limited to 'lib')
-rw-r--r--lib/oxidized/input/telnet.rb6
-rw-r--r--lib/oxidized/model/model.rb5
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb
index f946e92..2da459e 100644
--- a/lib/oxidized/input/telnet.rb
+++ b/lib/oxidized/input/telnet.rb
@@ -25,7 +25,11 @@ module Oxidized
Log.debug "Telnet: #{cmd} @#{@node.name}"
args = { 'String' => cmd }
args.merge!({ 'Match' => expect, 'Timeout' => @timeout }) if expect
- @telnet.cmd args
+ begin
+ @telnet.cmd args
+ rescue Timeout::Error
+ return false
+ end
end
private
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb
index fb27143..8f7b14f 100644
--- a/lib/oxidized/model/model.rb
+++ b/lib/oxidized/model/model.rb
@@ -40,6 +40,7 @@ module Oxidized
def cmd string, &block
out = @input.cmd string
+ return false unless out
self.class.cmds[:all].each do |all_block|
out = instance_exec out, &all_block
end
@@ -58,7 +59,9 @@ module Oxidized
def get
data = ''
self.class.cmds[:cmd].each do |command, block|
- data << (cmd command, &block).to_s
+ out = cmd command, &block
+ return false unless out
+ data << out.to_s
end
data << main.to_s if respond_to? :main
data