Method: Beaker::Perf#setup_perf_on_host

Defined in:
lib/beaker/perf.rb

#setup_perf_on_host(host) ⇒ void

This method returns an undefined value.

Install sysstat if required and perform any modifications needed to make sysstat work.

Parameters:

  • host (Host)

    The host we are working with



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/beaker/perf.rb', line 28

def setup_perf_on_host(host)
  @logger.perf_output("Setup perf on host: " + host)
  # Install sysstat if required
  if PERF_SUPPORTED_PLATFORMS.match?(host['platform'])
    PERF_PACKAGES.each do |pkg|
      host.install_package pkg if not host.check_for_package pkg
    end
  else
    @logger.perf_output("Perf (sysstat) not supported on host: " + host)
  end

  if /debian|ubuntu/.match?(host['platform'])
    @logger.perf_output("Modify /etc/default/sysstat on Debian and Ubuntu platforms")
    host.exec(Command.new('sed -i s/ENABLED=\"false\"/ENABLED=\"true\"/ /etc/default/sysstat'))
  elsif /opensuse|sles/.match?(host['platform'])
    @logger.perf_output("Creating symlink from /etc/sysstat/sysstat.cron to /etc/cron.d")
    host.exec(Command.new('ln -s /etc/sysstat/sysstat.cron /etc/cron.d'), :acceptable_exit_codes => [0, 1])
  end
  if @options[:collect_perf_data]&.include?('aggressive')
    @logger.perf_output("Enabling aggressive sysstat polling")
    if /debian|ubuntu/.match?(host['platform'])
      host.exec(Command.new('sed -i s/5-55\\\/10/*/ /etc/cron.d/sysstat'))
    elsif /amazon|centos|el|fedora|oracle|redhat|scientific/.match?(host['platform'])
      host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
    end
  end
  return unless PERF_START_PLATFORMS.match?(host['platform']) # SLES doesn't need this step

  host.exec(Command.new('service sysstat start'))
end