Class: MPstat
- Inherits:
-
Object
show all
- Includes:
- RunCommand
- Defined in:
- lib/city_watch/commands/mpstat.rb
Instance Method Summary
collapse
Methods included from RunCommand
#command_line, #command_output, included, #options, #set_opts, #supported?
Instance Method Details
#command_line_opts ⇒ Object
7
8
9
|
# File 'lib/city_watch/commands/mpstat.rb', line 7
def command_line_opts
"#{options[:interval]} #{options[:times]}"
end
|
#data ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/city_watch/commands/mpstat.rb', line 11
def data
= false
command_output.split("\n").map {|line| line.split("\s") }.inject([]) do |output,line|
if line[1] == "CPU"
= line.map {|hdr| hdr.gsub(/%/,'').to_sym}
[0] = :run
elsif
pkt = {}
line.each_with_index do |itm,idx|
pkt[[idx]] = itm
end
output << pkt
end
output
end
end
|