Sha256: 66af73096431bc15c48c1059cf3747e18686eb2c082b3b3f5346f3ceba82d4ad

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

Fiveruns::Dash.register_recipe :ruby, :url => 'http://dash.fiveruns.com' do |metrics|
  
  # TODO: Support Windows
  Fiveruns::Dash.host.execute_on_unix do
  
    metrics.absolute :vsz, 
      "Virtual Memory Usage", "The amount of virtual memory used by this process", 
      :unit => 'kbytes', :scope => :host do 
      Integer(`ps -o vsz -p #{Process.pid}`[/(\d+)/, 1])
    end
    metrics.absolute :rss, "Resident Memory Usage", 
      "The amount of physical memory used by this process", 
      :unit => 'kbytes',
      :scope => :host do
      Integer(`ps -o rss -p #{Process.pid}`[/(\d+)/, 1])
    end
    metrics.percentage :pmem, 
    "Resident Memory Usage", 
    "Percentage of Resident Memory Usage", 
    :scope => :host do
      Float(`ps -o pmem -p #{Process.pid}`[/(\d+\.\d+)/, 1])
    end

    if RUBY_PLATFORM == 'java'
      Fiveruns::Dash.logger.warn "Cannot collect CPU usage data on JRuby"
    else
      metrics.percentage :cpu, 
        'CPU Usage', 
        'Percentage CPU Usage',
        :scope => :host do
        before = Thread.current[:dash_utime] ||= Process.times.utime
        after = Process.times.utime
        this_minute = after - before
        Thread.current[:dash_utime] = after
        (this_minute / 60) * 100.00
      end
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fiveruns-dash-ruby-0.8.10 recipes/ruby.rb
fiveruns-dash-ruby-0.8.6 recipes/ruby.rb
fiveruns-dash-ruby-0.8.8 recipes/ruby.rb
fiveruns-dash-ruby-0.8.9 recipes/ruby.rb