summaryrefslogtreecommitdiff
path: root/lib/oxidized/input
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/input')
-rw-r--r--lib/oxidized/input/cli.rb3
-rw-r--r--lib/oxidized/input/ftp.rb6
-rw-r--r--lib/oxidized/input/ssh.rb18
-rw-r--r--lib/oxidized/input/telnet.rb6
4 files changed, 17 insertions, 16 deletions
diff --git a/lib/oxidized/input/cli.rb b/lib/oxidized/input/cli.rb
index 22d188c..731b459 100644
--- a/lib/oxidized/input/cli.rb
+++ b/lib/oxidized/input/cli.rb
@@ -1,6 +1,7 @@
module Oxidized
class Input
module CLI
+ attr_reader :node
def initialize
@post_login = []
@@ -10,7 +11,7 @@ module Oxidized
def get
connect_cli
- d = @node.model.get
+ d = node.model.get
disconnect
d
end
diff --git a/lib/oxidized/input/ftp.rb b/lib/oxidized/input/ftp.rb
index 70db60c..93cdb38 100644
--- a/lib/oxidized/input/ftp.rb
+++ b/lib/oxidized/input/ftp.rb
@@ -18,7 +18,7 @@ module Oxidized
def connect node
@node = node
@node.model.cfg['ftp'].each { |cb| instance_exec(&cb) }
- @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ftp", 'w') if CFG.input.debug?
+ @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ftp", 'w') if Oxidized.config.input.debug?
@ftp = Net::FTP.new @node.ip, @node.auth[:username], @node.auth[:password]
connected?
end
@@ -28,7 +28,7 @@ module Oxidized
end
def cmd file
- Log.debug "FTP: #{file} @ #{@node.name}"
+ Oxidized.logger.debug "FTP: #{file} @ #{@node.name}"
@ftp.getbinaryfile file, nil
end
@@ -47,7 +47,7 @@ module Oxidized
@ftp.close
#rescue Errno::ECONNRESET, IOError
ensure
- @log.close if CFG.input.debug?
+ @log.close if Oxidized.config.input.debug?
end
end
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb
index 21fb02c..476a786 100644
--- a/lib/oxidized/input/ssh.rb
+++ b/lib/oxidized/input/ssh.rb
@@ -19,11 +19,11 @@ module Oxidized
@node = node
@output = ''
@node.model.cfg['ssh'].each { |cb| instance_exec(&cb) }
- secure = CFG.input.ssh.secure
- @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ssh", 'w') if CFG.input.debug?
+ secure = Oxidized.config.input.ssh.secure
+ @log = File.open(Oxidized::Config::Crash + "-#{@node.ip}-ssh", 'w') if Oxidized.config.input.debug?
port = vars(:ssh_port) || 22
@ssh = Net::SSH.start @node.ip, @node.auth[:username], :port => port.to_i,
- :password => @node.auth[:password], :timeout => CFG.timeout,
+ :password => @node.auth[:password], :timeout => Oxidized.config.timeout,
:paranoid => secure,
:auth_methods => %w(none publickey password keyboard-interactive),
:number_of_password_prompts => 0
@@ -42,8 +42,8 @@ module Oxidized
@ssh and not @ssh.closed?
end
- def cmd cmd, expect=@node.prompt
- Log.debug "SSH: #{cmd} @ #{@node.name}"
+ def cmd cmd, expect=node.prompt
+ Oxidized.logger.debug "SSH: #{cmd} @ #{node.name}"
if @exec
@ssh.exec! cmd
else
@@ -64,17 +64,17 @@ module Oxidized
def disconnect
disconnect_cli
# if disconnect does not disconnect us, give up after timeout
- Timeout::timeout(CFG.timeout) { @ssh.loop }
+ Timeout::timeout(Oxidized.config.timeout) { @ssh.loop }
rescue Errno::ECONNRESET, Net::SSH::Disconnect, IOError
ensure
- @log.close if CFG.input.debug?
+ @log.close if Oxidized.config.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?
+ @log.print data if Oxidized.config.input.debug?
@output << data
@output = @node.model.expects @output
end
@@ -109,7 +109,7 @@ module Oxidized
end
def expect regexp
- Timeout::timeout(CFG.timeout) do
+ Timeout::timeout(Oxidized.config.timeout) do
@ssh.loop(0.1) do
sleep 0.1
not @output.match regexp
diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb
index bf0140c..e9fd7d9 100644
--- a/lib/oxidized/input/telnet.rb
+++ b/lib/oxidized/input/telnet.rb
@@ -8,7 +8,7 @@ module Oxidized
def connect node
@node = node
- @timeout = CFG.timeout
+ @timeout = Oxidized.config.timeout
@node.model.cfg['telnet'].each { |cb| instance_exec(&cb) }
port = vars(:telnet_port) || 23
@@ -16,7 +16,7 @@ module Oxidized
'Port' => port.to_i,
'Timeout' => @timeout,
'Model' => @node.model }
- opt['Output_log'] = Oxidized::Config::Crash + "-#{@node.ip}-telnet" if CFG.input.debug?
+ opt['Output_log'] = Oxidized::Config::Crash + "-#{@node.ip}-telnet" if Oxidized.config.input.debug?
@telnet = Net::Telnet.new opt
if @node.auth[:username] and @node.auth[:username].length > 0
@@ -37,7 +37,7 @@ module Oxidized
end
def cmd cmd, expect=@node.prompt
- Log.debug "Telnet: #{cmd} @#{@node.name}"
+ Oxidized.logger.debug "Telnet: #{cmd} @#{@node.name}"
args = { 'String' => cmd }
args.merge!({ 'Match' => expect, 'Timeout' => @timeout }) if expect
@telnet.cmd args