Class: Instana::Backend::ProcessInfo

Inherits:
SimpleDelegator
  • Object
show all
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

Since:

  • 1.197.0

Instance Method Summary collapse

Instance Method Details

#argumentsObject

Since:

  • 1.197.0



15
16
17
18
# File 'lib/instana/backend/process_info.rb', line 15

def arguments
  _, *arguments = cmdline.split(' ')
  clean_arguments(arguments)
end

#cpusetObject

Since:

  • 1.197.0



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_namespaceObject

Since:

  • 1.197.0



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

Returns:

  • (Boolean)

Since:

  • 1.197.0



39
40
41
# File 'lib/instana/backend/process_info.rb', line 39

def in_container?
  !cpuset.nil? && cpuset != '/'
end

#memory_usedObject

Since:

  • 1.197.0



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

#nameObject

Since:

  • 1.197.0



10
11
12
13
# File 'lib/instana/backend/process_info.rb', line 10

def name
  cmdline
    .split(' ').first
end

#parent_pidObject

Since:

  • 1.197.0



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_pidObject

Since:

  • 1.197.0



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