class RhaDaemon

RhaDaemon controls the heartbeat daemon

Attributes

debug_level[RW]

Increment debugging level. Higher levels are more verbose.

option[RW]

Set heartbeat daemon option; This will set an arbitrary heartbeat option.

path_to_heartbeat[RW]

Alternate path to heartbeat. If this is not set, environment path is used.

Public Class Methods

new() click to toggle source

Returns a new RhaDaemon Object

# File lib/rha/daemon.rb, line 37
def initialize()
end

Public Instance Methods

reload() click to toggle source

Reload heartbeat. This option is functionally identical to sending a running heartbeat process a HUP signal. If the configuration has not changed, then this option is essentially a no-op. If ha.cf or authkeys has changed, then heartbeat will re-read these files and update its configuration.

# File lib/rha/daemon.rb, line 47
def reload
  tmp = Tempfile.new('tmp')
  command = option_string() + "-r " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
report() click to toggle source

Report heartbeat status.

# File lib/rha/daemon.rb, line 93
def report
  tmp = Tempfile.new('tmp')
  command = option_string() + "-k " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
restart() click to toggle source

Heartbeat restart exec flag (internal use only).

# File lib/rha/daemon.rb, line 116
def restart
  tmp = Tempfile.new('tmp')
  command = option_string() + "-R " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
restart_with_current_resources() click to toggle source

Heartbeat current resource state for restart (internal use only).

# File lib/rha/daemon.rb, line 162
def restart_with_current_resources
  tmp = Tempfile.new('tmp')
  command = option_string() + "-R -C " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
status() click to toggle source

Report heartbeat status.

# File lib/rha/daemon.rb, line 139
def status
  tmp = Tempfile.new('tmp')
  command = option_string() + "-s " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
stop() click to toggle source

Kill (stop) heartbeat.

# File lib/rha/daemon.rb, line 70
def stop
  tmp = Tempfile.new('tmp')
  command = option_string() + "-k " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end
version() click to toggle source

Print out heartbeat version.

# File lib/rha/daemon.rb, line 185
def version
  tmp = Tempfile.new('tmp')
  command = option_string() + "-V " + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end

Private Instance Methods

option_string() click to toggle source
# File lib/rha/daemon.rb, line 207
def option_string()

  unless @path_to_heartbeat
    ostring = "heartbeat "
  else
    ostring = @path_to_heartbeat + " "
  end

  if @option
    ostring += @option + " "
  end

  if @debug_level
    ostring += "-d " + @debug_level
  end

  return ostring

end