diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-19 14:24:40 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-19 14:24:40 +0000 |
commit | f8fde5b7bba478a29feb2cb7fad562948ca80c46 (patch) | |
tree | 02c7210504e122cf1a0bac749eb0d5179f1123b4 /lib | |
parent | f62134a41533d121fd881cc038976bee27f09b86 (diff) |
Resolve IP correctly
Diffstat (limited to 'lib')
-rw-r--r-- | lib/custodian/alerter.rb | 4 |
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 |