Class: Beaker::Perf
- Inherits:
-
Object
- Object
- Beaker::Perf
- Defined in:
- lib/beaker/perf.rb
Overview
The Beaker Perf class. A single instance is created per Beaker run.
Instance Method Summary collapse
-
#get_perf_data(host, perf_start, perf_end) ⇒ void
If host is a supported (ie linux) platform, generate a performance report.
-
#initialize(hosts, options) ⇒ void
constructor
Create the Perf instance and runs setup_perf_on_host on all hosts if –collect-perf-data was used as an option on the Baker command line invocation.
-
#print_perf_info ⇒ void
Iterate over all hosts, calling get_perf_data.
-
#setup_perf_on_host(host) ⇒ void
Some systems need special modification to make sysstat work.
Constructor Details
#initialize(hosts, options) ⇒ void
Create the Perf instance and runs setup_perf_on_host on all hosts if –collect-perf-data was used as an option on the Baker command line invocation. Instances of this class do not hold state and its methods are helpers for remotely executing tasks for performance data gathering with sysstat/sar
13 14 15 16 17 18 19 |
# File 'lib/beaker/perf.rb', line 13 def initialize( hosts, ) @hosts = hosts @options = @logger = [:logger] @perf_timestamp = Time.now @hosts.map { |h| setup_perf_on_host(h) } end |
Instance Method Details
#get_perf_data(host, perf_start, perf_end) ⇒ void
This method returns an undefined value.
If host is a supported (ie linux) platform, generate a performance report
51 52 53 54 55 56 |
# File 'lib/beaker/perf.rb', line 51 def get_perf_data(host, perf_start, perf_end) @logger.perf_output("Getting perf data for host: " + host) if host['platform'] =~ /debian|ubuntu|redhat|centos|sles/ host.exec(Command.new("sar -A -s #{perf_start.strftime("%H:%M:%S")} -e #{perf_end.strftime("%H:%M:%S")}")) end end |
#print_perf_info ⇒ void
This method returns an undefined value.
Iterate over all hosts, calling get_perf_data
41 42 43 44 |
# File 'lib/beaker/perf.rb', line 41 def print_perf_info() @perf_end_timestamp = Time.now @hosts.map { |h| get_perf_data(h, @perf_timestamp, @perf_end_timestamp) } end |
#setup_perf_on_host(host) ⇒ void
This method returns an undefined value.
Some systems need special modification to make sysstat work. This is done here.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/beaker/perf.rb', line 24 def setup_perf_on_host(host) @logger.perf_output("Setup perf on host: " + host) if host['platform'] =~ /debian|ubuntu/ @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 host['platform'] =~ /sles/ @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 host['platform'] =~ /debian|ubuntu|redhat|centos/ # SLES doesn't need this step host.exec(Command.new('service sysstat start')) end end |