Droid::Monitor

Monitoring Android apu or memory usage and create their simple graph with Google API.

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'droid-monitor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install droid-monitor

Usage

See under sample file in this repository. The sample use clockwork to run ruby script in particular terms.

CPU

# initialize
@cpu = Droid::Monitor::Cpu.new( { package: "com.android.chrome" } )

# save data into @cpu.cpu_usage
@cpu.store_dumped_cpu_usage

# export data into filename as google api format
filename = "sample_data.txt"
@cpu.save_cpu_usage_as_google_api(filename)

# export data into filename which is used the above command.
output_file_path = "sample.html"
graph_opts = { title: "Example", header1: "this graph is just sample"}
@cpu.create_graph(filename, graph_opts, output_file_path)

Graph

Memory

# initialize
# You can specify target devices with providing device serial which is provided via adb devices.
@memory = Droid::Monitor::Cpu.new( { package: "com.android.chrome", device_serial: "device_serials"} )

# save data into @memory.memory_usage
@memory.store_dumped_memory_details_usage

# export data into filename as google api format
filename = "sample_data.txt"
@memory.save_memory_details_as_google_api(filename)

# export data into filename which is used the above command.
output_file_path = "sample.html"
graph_opts = { title: "Example", header1: "this graph is just sample"}
@cpu.create_graph(filename, graph_opts, output_file_path)

Graph

Notice

  1. Some browser, like Google Chrome, can't see local file via page. So, you should see report html file via FireFox as example.

License

MIT license. Please see here.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/droid-monitor/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request