Class: Pinger
- Inherits:
-
Object
- Object
- Pinger
- Defined in:
- lib/pinger.rb
Class Method Summary collapse
Class Method Details
.external(host) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/pinger.rb', line 15 def self.external(host) result = false ping = `ping -q -c 1 #{host}` result = ping.split("\n").last.split("=").last.split('/')[1] if $?.exitstatus == 0 result end |
.http(uri) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/pinger.rb', line 2 def self.http(uri) result = true begin RestClient::Resource.new(uri, :timeout => 5, :open_timeout => 5).get rescue RestClient::Forbidden rescue Exception => e result = e.to_s end result end |