class CheckHostIp

Attributes

host[RW]

@!attribute

ip[RW]

@!attribute

Public Class Methods

new(host, ip) click to toggle source

@param: host (String) The host name @param: ip (String) The host IP

# File lib/check_host/check_host_ip.rb, line 10
def initialize(host, ip)
  @host = host
  @ip   = ip
end

Public Instance Methods

notify() click to toggle source

Sends an email if result? is true @return Boolean

# File lib/check_host/check_host_ip.rb, line 17
def notify
  if result?
    SendMail.new
    true
  else
    false
  end
end

Private Instance Methods

cmd() click to toggle source

Runs the host cmd and returns just the A record example: “fawazalhokairfashion.com has address 91.109.13.176\n” @return String

# File lib/check_host/check_host_ip.rb, line 30
def cmd
  `host -t A #{host}`
end
result?() click to toggle source

Checks whether a string contains the ip address @return Boolean

# File lib/check_host/check_host_ip.rb, line 36
def result?
  !cmd.include? ip
end