summaryrefslogtreecommitdiff
path: root/lib/oxidized/node.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/node.rb')
-rw-r--r--lib/oxidized/node.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb
index 2b15d4e..4105da0 100644
--- a/lib/oxidized/node.rb
+++ b/lib/oxidized/node.rb
@@ -15,7 +15,8 @@ module Oxidized
ip_addr, _ = opt[:ip].to_s.split("/")
Oxidized.logger.debug 'IPADDR %s' % ip_addr.to_s
@name = opt[:name]
- @ip = IPAddr.new(ip_addr).to_s rescue nil
+ @ip = @name unless Oxidized.config.resolve_dns?
+ @ip ||= IPAddr.new(ip_addr).to_s rescue nil
@ip ||= Resolv.new.getaddress @name
@group = opt[:group]
@input = resolve_input opt
@@ -39,7 +40,7 @@ module Oxidized
cfg_name = input.to_s.split('::').last.downcase
next unless @model.cfg[cfg_name] and not @model.cfg[cfg_name].empty?
@model.input = input = input.new
- if config=run_input(input)
+ if config = run_input(input)
Oxidized.logger.debug "lib/oxidized/node.rb: #{input.class.name} ran for #{name} successfully"
status = :success
break
@@ -55,7 +56,7 @@ module Oxidized
def run_input input
rescue_fail = {}
[input.class::RescueFail, input.class.superclass::RescueFail].each do |hash|
- hash.each do |level,errors|
+ hash.each do |level, errors|
errors.each do |err|
rescue_fail[err] = level
end
@@ -64,9 +65,9 @@ module Oxidized
begin
input.connect(self) and input.get
rescue *rescue_fail.keys => err
- resc = ''
+ resc = ''
if not level = rescue_fail[err.class]
- resc = err.class.ancestors.find{|e|rescue_fail.keys.include? e}
+ resc = err.class.ancestors.find { |e| rescue_fail.keys.include? e }
level = rescue_fail[resc]
resc = " (rescued #{resc})"
end
@@ -196,20 +197,20 @@ module Oxidized
end
end
- def resolve_key key, opt, global=nil
+ def resolve_key key, opt, global = nil
# resolve key, first get global, then get group then get node config
key_sym = key.to_sym
key_str = key.to_s
value = global
Oxidized.logger.debug "node.rb: resolving node key '#{key}', with passed global value of '#{value}' and node value '#{opt[key_sym]}'"
- #global
+ # global
if not value and Oxidized.config.has_key?(key_str)
value = Oxidized.config[key_str]
Oxidized.logger.debug "node.rb: setting node key '#{key}' to value '#{value}' from global"
end
- #group
+ # group
if Oxidized.config.groups.has_key?(@group)
if Oxidized.config.groups[@group].has_key?(key_str)
value = Oxidized.config.groups[@group][key_str]
@@ -217,7 +218,7 @@ module Oxidized
end
end
- #model
+ # model
# FIXME: warning: instance variable @model not initialized
if Oxidized.config.models.has_key?(@model.class.name.to_s.downcase)
if Oxidized.config.models[@model.class.name.to_s.downcase].has_key?(key_str)
@@ -226,7 +227,7 @@ module Oxidized
end
end
- #node
+ # node
value = opt[key_sym] || value
Oxidized.logger.debug "node.rb: returning node key '#{key}' with value '#{value}'"
value
@@ -239,6 +240,5 @@ module Oxidized
def is_gitcrypt? opt
(opt[:output] || Oxidized.config.output.default) == 'gitcrypt'
end
-
end
end