summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/alerter.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/custodian/alerter.rb b/lib/custodian/alerter.rb
index e7befaf..da3571e 100644
--- a/lib/custodian/alerter.rb
+++ b/lib/custodian/alerter.rb
@@ -52,10 +52,17 @@ class Alerter
resolved = target
else
begin
- Socket.getaddrinfo(target, 'echo').each do |a|
- resolved = a[3] if ( a )
+ timeout( 4 ) do
+
+ begin
+ Socket.getaddrinfo(target, 'echo').each do |a|
+ resolved = a[3] if ( a )
+ end
+ rescue SocketError
+ resolved = nil
+ end
end
- rescue SocketError
+ rescue Timeout::Error => e
resolved = nil
end
end
@@ -93,9 +100,15 @@ class Alerter
raise ArgumentError, "Address must not be nil" if ( address.nil? )
begin
- Resolv.new.getname(address)
- rescue
- nil
+ timeout( 4 ) do
+ begin
+ Resolv.new.getname(address)
+ rescue
+ nil
+ end
+ end
+ rescue Timeout::Error => e
+ resolved = nil
end
end