Sha256: c4e8e3f4cd10230c6ef5c2c3b1069870dcab8f0762d174d31f6c5800b461f01e
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module God module Conditions class Ping < PollCondition attr_accessor :timeout, :host, :trigger_on def initialize super self.timeout = 2 # s self.host = nil self.trigger_on=true end def valid? valid = true valid &= complain("Attribute 'host' must be specified", self) if self.host.nil? valid &= complain("Attribute 'timeout' must be specified", self) if self.timeout.nil? valid end def test # ping_time = `df -P | grep -i " #{self.mount_point}$" | awk '{print $5}' | sed 's/%//'` cmd = "ping -t #{self.timeout} #{self.host}" # puts cmd ping_result = `#{cmd}` # if ping_result=~ /no route to host/ # self.info "no route to host: #{self.host}" # return false # end if ping_result=~/time=/ self.info = "Server reachable via ping!" return self.trigger_on end self.info = "Server unreachable via ping!!!" return !self.trigger_on end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
olgen-god-0.8.1 | lib/god/conditions/ping.rb |
olgen-god-0.8.0 | lib/god/conditions/ping.rb |