From f8fde5b7bba478a29feb2cb7fad562948ca80c46 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 19 Nov 2012 14:24:40 +0000 Subject: Resolve IP correctly --- lib/custodian/alerter.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/custodian') 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 -- cgit v1.2.1