Class: Instana::Backend::ProcessInfo
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Instana::Backend::ProcessInfo
- Defined in:
- lib/instana/backend/process_info.rb
Overview
Wrapper around Sys::ProcTable that adds support for reading the /proc file system for extra information around containers
Instance Method Summary collapse
- #arguments ⇒ Object
- #cpuset ⇒ Object
- #from_parent_namespace ⇒ Object
- #in_container? ⇒ Boolean
- #memory_used ⇒ Object
- #name ⇒ Object
- #parent_pid ⇒ Object
- #sched_pid ⇒ Object
Instance Method Details
#arguments ⇒ Object
15 16 17 18 |
# File 'lib/instana/backend/process_info.rb', line 15 def arguments _, *arguments = cmdline.split(' ') clean_arguments(arguments) end |
#cpuset ⇒ Object
32 33 34 35 36 37 |
# File 'lib/instana/backend/process_info.rb', line 32 def cpuset path = "/proc/#{pid}/cpuset" return unless File.exist?(path) File.read(path).strip end |
#from_parent_namespace ⇒ Object
28 29 30 |
# File 'lib/instana/backend/process_info.rb', line 28 def from_parent_namespace !in_container? || in_container? && sched_pid != pid end |
#in_container? ⇒ Boolean
39 40 41 |
# File 'lib/instana/backend/process_info.rb', line 39 def in_container? !cpuset.nil? && cpuset != '/' end |
#memory_used ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/instana/backend/process_info.rb', line 50 def memory_used if RbConfig::CONFIG['host_os'].include?('darwin') rss else rss * 4096 end end |
#name ⇒ Object
10 11 12 13 |
# File 'lib/instana/backend/process_info.rb', line 10 def name cmdline .split(' ').first end |
#parent_pid ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/instana/backend/process_info.rb', line 20 def parent_pid if in_container? && !sched_pid.nil? sched_pid else pid end end |
#sched_pid ⇒ Object
43 44 45 46 47 48 |
# File 'lib/instana/backend/process_info.rb', line 43 def sched_pid path = '/proc/self/sched' return unless File.exist?(path) File.read(path).match(/\d+/).to_s.to_i end |