A simple ruby client for Check-Host.net API.
It was forked from checkhost-ruby to bring higher code quality.
Add this line to your application's Gemfile (currently under development):
gem 'checkhost-client'And then execute:
$ bundle
Array containing the nodes codes used for the check.
Initializes a new instance to check <host>. Note this doesn't actually begin any check.
<type>: one of the supported check protocols (default: http)
<max_nodes>: max number of nodes to run the check with (default: 3)
Sends the check API request.
Send the check's result API request.
Returns an hash containing the current check results, with nodes codes as keys.
Returns an array containing country code, country name and location of the node.
<code>: node code (see nodes attribute)
#!/usr/bin/env ruby
require 'checkhost'
res = {}
google = CheckHost.new('google.com', {:type => 'http', :max_nodes => 3})
google.run
res = google.check until !res.empty? && !res.has_value?(nil)
print 'Check nodes: '
google.nodes.each do |node|
node = google.node_info(node)
print "#{node[:country]}(#{node[:location]}) "
end
puts "\n\n"
res.each do |node, result|
country = google.node_info(node)[:country]
message = result[:message]
time = result[:time]
puts "#{country}: #{message} (in #{time}ms)"
end
Check nodes: Italy(Milano) United Kingdom(London) Netherlands(Amsterdam)
Italy: Found (in 16ms)
United Kingdom: Found (in 4ms)
Netherlands: Found (in 14ms)
checkhost-client-ruby is licensed under the MIT license. For a copy of the license refer to the LICENSE file.