lib/beaker/perf.rb in beaker-4.38.1 vs lib/beaker/perf.rb in beaker-4.39.0
- old
+ new
@@ -27,36 +27,36 @@
# @param [Host] host The host we are working with
# @return [void]
def setup_perf_on_host(host)
@logger.perf_output("Setup perf on host: " + host)
# Install sysstat if required
- if host['platform'] =~ PERF_SUPPORTED_PLATFORMS
+ if PERF_SUPPORTED_PLATFORMS.match?(host['platform'])
PERF_PACKAGES.each do |pkg|
if not host.check_for_package pkg
host.install_package pkg
end
end
else
@logger.perf_output("Perf (sysstat) not supported on host: " + host)
end
- if host['platform'] =~ /debian|ubuntu|cumulus/
+ if /debian|ubuntu|cumulus/.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 host['platform'] =~ /opensuse|sles/
+ 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] =~ /aggressive/
+ if @options[:collect_perf_data]&.include?('aggressive')
@logger.perf_output("Enabling aggressive sysstat polling")
- if host['platform'] =~ /debian|ubuntu/
+ if /debian|ubuntu/.match?(host['platform'])
host.exec(Command.new('sed -i s/5-55\\\/10/*/ /etc/cron.d/sysstat'))
- elsif host['platform'] =~ /centos|el|fedora|oracle|redhat|scientific/
+ elsif /centos|el|fedora|oracle|redhat|scientific/.match?(host['platform'])
host.exec(Command.new('sed -i s/*\\\/10/*/ /etc/cron.d/sysstat'))
end
end
- if host['platform'] =~ PERF_START_PLATFORMS # SLES doesn't need this step
+ if PERF_START_PLATFORMS.match?(host['platform']) # SLES doesn't need this step
host.exec(Command.new('service sysstat start'))
end
end
# Iterate over all hosts, calling get_perf_data
@@ -71,11 +71,11 @@
# @param [Time] perf_start The beginning time for the SAR report
# @param [Time] perf_end The ending time for the SAR report
# @return [void] The report is sent to the logging output
def get_perf_data(host, perf_start, perf_end)
@logger.perf_output("Getting perf data for host: " + host)
- if host['platform'] =~ PERF_SUPPORTED_PLATFORMS # All flavours of Linux
- if not @options[:collect_perf_data] =~ /aggressive/
+ if PERF_SUPPORTED_PLATFORMS.match?(host['platform']) # All flavours of Linux
+ if not @options[:collect_perf_data]&.include?('aggressive')
host.exec(Command.new("sar -A -s #{perf_start.strftime("%H:%M:%S")} -e #{perf_end.strftime("%H:%M:%S")}"),:acceptable_exit_codes => [0,1,2])
end
if (defined? @options[:graphite_server] and not @options[:graphite_server].nil?) and
(defined? @options[:graphite_perf_data] and not @options[:graphite_perf_data].nil?)
export_perf_data_to_graphite(host)