Sha256: 6a6b20556f68f9cc3d48b6aea6c0bf42fd63835964ea2f698b5b085252f9f9f4
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
# This is an example of a signal which will interupt the SignalRunner when # something important hapens. As you can see, all you need to do is implement # the #start method. This should launch into a new Thread doing whatever you # need. When something significant happens you should call @client.report and # give it some data to report in the form of a Hash. # # To deal with data on the server side, create a class that extends # Smoke::SignalProcesor. # module Smoke class RemotePortStatusCheck < Smoke::Signal HOSTS_PORTS_AND_STATUSES = [ [ "xeriom.net", 80, :open ], [ "barkingiguana.com", 80, :open ], [ "localhost", 80, :down ] ] def start HOSTS_PORTS_AND_STATUSES.map do |check| Thread.new(@client, check) do |client, c| host, port, desired_status = *c loop do current_status = begin TCPSocket.new(host, port) :open rescue Errno::ECONNREFUSED :closed end if current_status != desired_status client.report self, { :host => host, :port => port, :status => current_status } end sleep 15 end end end loop end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smoke-0.0.3 | contrib/signals/smoke/remote_port_status_check.rb |