Class: GitLab::Monitor::ProcessStats
- Inherits:
-
Object
- Object
- GitLab::Monitor::ProcessStats
- Defined in:
- lib/gitlab_monitor/process.rb
Overview
A helper class to stats from /proc/<pid>/stat
See: man 5 proc
It takes a pid
Instance Method Summary collapse
- #cpu_time ⇒ Object
-
#initialize(pid) ⇒ ProcessStats
constructor
A new instance of ProcessStats.
- #rss ⇒ Object
- #start_time ⇒ Object
- #valid? ⇒ Boolean
- #vsize ⇒ Object
Constructor Details
#initialize(pid) ⇒ ProcessStats
Returns a new instance of ProcessStats.
16 17 18 19 20 |
# File 'lib/gitlab_monitor/process.rb', line 16 def initialize(pid) @pid = pid @user_hertz = retrieve_user_hertz @stats = populate_info end |
Instance Method Details
#cpu_time ⇒ Object
26 27 28 |
# File 'lib/gitlab_monitor/process.rb', line 26 def cpu_time (@stats[14].to_i + @stats[15].to_i) / @user_hertz end |
#rss ⇒ Object
39 40 41 42 |
# File 'lib/gitlab_monitor/process.rb', line 39 def rss # Resident Set Size: number of pages the process has in real memory. @stats[24].to_i * 4096 end |
#start_time ⇒ Object
30 31 32 |
# File 'lib/gitlab_monitor/process.rb', line 30 def start_time @stats[22].to_i / @user_hertz end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/gitlab_monitor/process.rb', line 22 def valid? !@stats.nil? end |
#vsize ⇒ Object
34 35 36 37 |
# File 'lib/gitlab_monitor/process.rb', line 34 def vsize # Virtual memory size in bytes. @stats[23].to_i end |