summaryrefslogtreecommitdiff
path: root/lib/oxidized/input
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-08-08 21:26:45 +0300
committerSaku Ytti <saku@ytti.fi>2014-08-08 21:26:45 +0300
commit1f7ee60040690ececa0b2f114a21cd0af7475764 (patch)
treeb19d2279e615f636f9707a48c5aa6e7ace4fd0e2 /lib/oxidized/input
parent9d258c9e17a1b200060424cdaccb0355f757f124 (diff)
parent96d6c0213178241ab3170141906c152c6984e446 (diff)
Merge branch 'master' into cfg_as_object
Diffstat (limited to 'lib/oxidized/input')
-rw-r--r--lib/oxidized/input/ssh.rb3
-rw-r--r--lib/oxidized/input/telnet.rb8
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb
index e3fcede..62a31eb 100644
--- a/lib/oxidized/input/ssh.rb
+++ b/lib/oxidized/input/ssh.rb
@@ -20,6 +20,7 @@ module Oxidized
@output = ''
@node.model.cfg['ssh'].each { |cb| instance_exec(&cb) }
secure = CFG.input.ssh.secure
+ @log = File.open(CFG.input.debug?.to_s + '-ssh', 'w') if CFG.input.debug?
@ssh = Net::SSH.start @node.ip, @node.auth[:username],
:password => @node.auth[:password], :timeout => CFG.timeout,
:paranoid => secure
@@ -59,12 +60,14 @@ module Oxidized
Timeout::timeout(CFG.timeout) { @ssh.loop }
rescue Errno::ECONNRESET, Net::SSH::Disconnect, IOError
ensure
+ @log.close if CFG.input.debug?
(@ssh.close rescue true) unless @ssh.closed?
end
def shell_open ssh
@ses = ssh.open_channel do |ch|
ch.on_data do |_ch, data|
+ @log.print data if CFG.input.debug?
@output << data
@output = @node.model.expects @output
end
diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb
index d52ebf0..62f361e 100644
--- a/lib/oxidized/input/telnet.rb
+++ b/lib/oxidized/input/telnet.rb
@@ -10,8 +10,12 @@ module Oxidized
@node = node
@timeout = CFG.timeout
@node.model.cfg['telnet'].each { |cb| instance_exec(&cb) }
- @telnet = Net::Telnet.new 'Host' => @node.ip, 'Timeout' => @timeout,
- 'Model' => @node.model
+
+ opt = { 'Host' => @node.ip, 'Timeout' => @timeout,
+ 'Model' => @node.model }
+ opt['Output_log'] = CFG.input.debug?.to_s + '-telnet' if CFG.input.debug?
+
+ @telnet = Net::Telnet.new opt
expect username
@telnet.puts @node.auth[:username]
expect password