Class: PerfMonger::Command::SummaryCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- PerfMonger::Command::SummaryCommand
- Defined in:
- lib/perfmonger/command/summary.rb
Instance Method Summary collapse
-
#initialize ⇒ SummaryCommand
constructor
A new instance of SummaryCommand.
- #parse_args(argv) ⇒ Object
- #run(argv, summary_title = nil) ⇒ Object
Methods inherited from BaseCommand
register_alias, register_command
Constructor Details
#initialize ⇒ SummaryCommand
Returns a new instance of SummaryCommand.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/perfmonger/command/summary.rb', line 11 def initialize @parser = OptionParser.new @parser. = "Usage: perfmonger summary [options] LOG_FILE\n\nOptions:\n" @json = false @pager = nil @disk_only_regex = nil @parser.on('--json', "Output summary in JSON") do @json = true end @parser.on('-p', '--pager [PAGER]', "Use pager to see summary output.") do |pager| if pager.nil? if ENV['PAGER'].nil? puts("ERROR: No pager is available.") puts("ERROR: Please set PAGER or give pager name to --pager option.") puts(@parser.help) exit(false) else @pager = ENV['PAGER'] end else @pager = pager end end @parser.on('--disk-only REGEX', "Select disk devices that matches REGEX (Ex. 'sd[b-d]')") do |regex| @disk_only_regex = regex end end |
Instance Method Details
#parse_args(argv) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/perfmonger/command/summary.rb', line 47 def parse_args(argv) @parser.parse!(argv) if argv.size == 0 puts("ERROR: PerfMonger log file is required") puts(@parser.help) exit(false) end @logfile = argv.shift if ! File.exists?(@logfile) puts("ERROR: No such file: #{@logfile}") puts(@parser.help) exit(false) end end |
#run(argv, summary_title = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/perfmonger/command/summary.rb', line 64 def run(argv, summary_title = nil) parse_args(argv) summary_title ||= @logfile @summarizer_bin = ::PerfMonger::Command::CoreFinder.summarizer() if ! @summarizer_bin puts("[ERROR] no executable binary found.") exit(false) end cmd = [@summarizer_bin] if @json cmd << "-json" end if @disk_only_regex cmd << "-disk-only" cmd << @disk_only_regex end cmd << "-title" cmd << summary_title cmd << @logfile Process.exec(*cmd) end |