class GaddyGaddyCheck

Public Class Methods

new(extra) click to toggle source
# File lib/gg_check/gaddy_gaddy_check.rb, line 17
def initialize(extra)
   @extra = extra.split(',')
 end

Public Instance Methods

extra() click to toggle source

Will return extra info given as parameter

# File lib/gg_check/gaddy_gaddy_check.rb, line 24
def extra
 @extra
end
process_alive?(regexp) click to toggle source

Will check if a process is live

# File lib/gg_check/gaddy_gaddy_check.rb, line 51
def process_alive? (regexp)
  status, process_lines, stderr = run_cmd "ps -ef|grep -e '#{regexp}'|grep -v grep".strip
  process_lines.size > 0
end
run_cmd(cmd) click to toggle source

Will run a command and return: status, stdout, stderr

# File lib/gg_check/gaddy_gaddy_check.rb, line 32
def run_cmd cmd
  systemu cmd
end
socket(host,port,message,sleep_sec=1) click to toggle source

Will open a socket connection and send a message and wait for a result

# File lib/gg_check/gaddy_gaddy_check.rb, line 39
def socket(host,port,message,sleep_sec=1)
  Socket.tcp(host, port) {|sock|
    sock.print message
    sleep sleep_sec
    sock.close_write
    sock.read
  }
end