summaryrefslogtreecommitdiff
path: root/lib/custodian/alerter.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-19 14:24:40 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-19 14:24:40 +0000
commitf8fde5b7bba478a29feb2cb7fad562948ca80c46 (patch)
tree02c7210504e122cf1a0bac749eb0d5179f1123b4 /lib/custodian/alerter.rb
parentf62134a41533d121fd881cc038976bee27f09b86 (diff)
Resolve IP correctly
Diffstat (limited to 'lib/custodian/alerter.rb')
-rw-r--r--lib/custodian/alerter.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/custodian/alerter.rb b/lib/custodian/alerter.rb
index 202b372..30255f4 100644
--- a/lib/custodian/alerter.rb
+++ b/lib/custodian/alerter.rb
@@ -31,11 +31,12 @@ class Alerter
# Resolve an IP address
#
def resolve_ip( target )
+ resolved = nil
begin
timeout( 4 ) do
begin
Socket.getaddrinfo(target, 'echo').each do |a|
- resolved = a[3] if ( a )
+ resolved = a[2] if ( a )
end
rescue SocketError
resolved = nil
@@ -44,6 +45,7 @@ class Alerter
rescue Timeout::Error => e
resolved = nil
end
+ resolved
end