Class: OneApm::Collector::ShellPoller

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/collector/support/shell_poller.rb

Direct Known Subclasses

JrubyPoller, ProcPoller

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pidObject

Returns the value of attribute pid.



7
8
9
# File 'lib/one_apm/collector/support/shell_poller.rb', line 7

def pid
  @pid
end

Class Method Details

.kb_page_sizeObject



22
23
24
# File 'lib/one_apm/collector/support/shell_poller.rb', line 22

def self.kb_page_size
  @size ||= `getconf PAGE_SIZE`.to_f / 1024.0 rescue 4.0
end

Instance Method Details

#cpu_utilizationObject



13
14
15
16
# File 'lib/one_apm/collector/support/shell_poller.rb', line 13

def cpu_utilization
  @pid = Process.pid
  ps_float('%cpu') / 100.0
end

#memoryObject



9
10
11
# File 'lib/one_apm/collector/support/shell_poller.rb', line 9

def memory
  pids.inject(0.0){|m, pid| m + get_memory_by_pid(pid) }
end

#to_sObject



18
19
20
# File 'lib/one_apm/collector/support/shell_poller.rb', line 18

def to_s
  "ShellPoller from: ps -p #{pid}"
end