Sha256: fb205d75efc473230aa32d434db7a17a02b813887ced818bbec9154b8eb6830f

Contents?: true

Size: 532 Bytes

Versions: 42

Compression:

Stored size: 532 Bytes

Contents

class MPstat
	
	include RunCommand
	
	command :mpstat, :interval => 5, :times => 2
	
	def command_line_opts
		"#{options[:interval]} #{options[:times]}"
	end
	
	def data
		headers = false
		command_output.split("\n").map {|line| line.split("\s") }.inject([]) do |output,line|
			if line[1] == "CPU"
				headers = line.map {|hdr| hdr.gsub(/%/,'').to_sym}
				headers[0] = :run
			elsif headers
				pkt = {}
				line.each_with_index do |itm,idx|
					pkt[headers[idx]] = itm
				end
				output << pkt
			end
			output
		end
	end
	
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
city-watch-0.7.9 lib/city_watch/commands/mpstat.rb
city-watch-0.7.8 lib/city_watch/commands/mpstat.rb
city-watch-0.7.7 lib/city_watch/commands/mpstat.rb
city-watch-0.7.6 lib/city_watch/commands/mpstat.rb
city-watch-0.7.5 lib/city_watch/commands/mpstat.rb
city-watch-0.7.4 lib/city_watch/commands/mpstat.rb
city-watch-0.7.3 lib/city_watch/commands/mpstat.rb
city-watch-0.7.2 lib/city_watch/commands/mpstat.rb
city-watch-0.7.1 lib/city_watch/commands/mpstat.rb
city-watch-0.7.0 lib/city_watch/commands/mpstat.rb
city-watch-0.6.9 lib/city_watch/commands/mpstat.rb
city-watch-0.6.8 lib/city_watch/commands/mpstat.rb
city-watch-0.6.7 lib/city_watch/commands/mpstat.rb
city-watch-0.6.6 lib/city_watch/commands/mpstat.rb
city-watch-0.6.5 lib/city_watch/commands/mpstat.rb
city-watch-0.6.4 lib/city_watch/commands/mpstat.rb
city-watch-0.6.3 lib/city_watch/commands/mpstat.rb
city-watch-0.6.2 lib/city_watch/commands/mpstat.rb
city-watch-0.6.1 lib/city_watch/commands/mpstat.rb
city-watch-0.6.0 lib/city_watch/commands/mpstat.rb