Sha256: f5ac1232d41a457f749bedadbc8a69fb66d309d036ff0c387bc9b5054ae0e1b7
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 Bytes
Contents
require 'socket' require 'timeout' require 'bigdecimal' module HawatelTlb module WatchDog # Check node status # def watcher @group.each do |node| if node.state == 'enable' start = Time.now() port_open?(node) ? port_state = 'online' : port_state = 'offline' stop = Time.now() - start node.status = {:time => Time.now.to_i, :state => port_state, :respond_time => stop.round(4)} end end end private # Check if port is open # def port_open?(node) Timeout::timeout(node.timeout) do begin TCPSocket.new(node.host, node.port).close true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH false end end rescue Timeout::Error, SocketError false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hawatel_tlb-0.1.0 | lib/hawatel_tlb/watchdog.rb |