summaryrefslogtreecommitdiff
path: root/lib/oxidized/input/ssh.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2017-07-07 14:05:48 +0300
committerSaku Ytti <saku@ytti.fi>2017-07-07 14:05:48 +0300
commit72a6619986086df4d8db876ca0424f6bb6671b1b (patch)
treec248aae3c2f57bf228eb2884091d3d84a66c84da /lib/oxidized/input/ssh.rb
parent776386ea339b53b90284acf123e0dce5758b901c (diff)
add pre_loginfeature-pre_login
Diffstat (limited to 'lib/oxidized/input/ssh.rb')
-rw-r--r--lib/oxidized/input/ssh.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb
index 27e81e0..cca580b 100644
--- a/lib/oxidized/input/ssh.rb
+++ b/lib/oxidized/input/ssh.rb
@@ -24,7 +24,7 @@ module Oxidized
secure = Oxidized.config.input.ssh.secure
@log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ssh", 'w') if Oxidized.config.input.debug?
port = vars(:ssh_port) || 22
-
+
ssh_opts = {
:port => port.to_i,
:password => @node.auth[:password], :timeout => Oxidized.config.timeout,
@@ -47,15 +47,18 @@ module Oxidized
Oxidized.logger.debug "lib/oxidized/input/ssh.rb: Connecting to #{@node.name}"
@ssh = Net::SSH.start(@node.ip, @node.auth[:username], ssh_opts)
+ connected?
+ end
+
+ def login
unless @exec
shell_open @ssh
begin
- login
+ shell_login
rescue Timeout::Error
raise PromptUndetect, [ @output, 'not matching configured prompt', @node.prompt ].join(' ')
end
end
- connected?
end
def connected?
@@ -116,7 +119,7 @@ module Oxidized
# some models have SSH auth or terminal auth based on version of code
# if SSH is configured for terminal auth, we'll still try to detect prompt
- def login
+ def shell_login
if @username
match = expect username, @node.prompt
if match == username