Class: ServerMetrics::Processes::Process
- Inherits:
-
Object
- Object
- ServerMetrics::Processes::Process
- Defined in:
- lib/server_metrics/collectors/processes.rb
Overview
a thin wrapper around Sys:ProcTable’s ProcTableStruct. We’re using it to add some fields and behavior. Beyond what we’re adding, it just passes through to its instance of ProcTableStruct
Instance Attribute Summary collapse
-
#recent_cpu ⇒ Object
used to store the calculation of CPU since last sample.
-
#recent_cpu_percentage ⇒ Object
used to store the calculation of CPU since last sample.
Instance Method Summary collapse
- #combined_cpu ⇒ Object
-
#initialize(proctable_struct) ⇒ Process
constructor
A new instance of Process.
-
#method_missing(sym, *args, &block) ⇒ Object
delegate everything else to ProcTable::Struct.
Constructor Details
#initialize(proctable_struct) ⇒ Process
Returns a new instance of Process.
152 153 154 155 |
# File 'lib/server_metrics/collectors/processes.rb', line 152 def initialize(proctable_struct) @pts=proctable_struct @recent_cpu = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
delegate everything else to ProcTable::Struct
163 164 165 |
# File 'lib/server_metrics/collectors/processes.rb', line 163 def method_missing(sym, *args, &block) @pts.send sym, *args, &block end |
Instance Attribute Details
#recent_cpu ⇒ Object
used to store the calculation of CPU since last sample
151 152 153 |
# File 'lib/server_metrics/collectors/processes.rb', line 151 def recent_cpu @recent_cpu end |
#recent_cpu_percentage ⇒ Object
used to store the calculation of CPU since last sample
151 152 153 |
# File 'lib/server_metrics/collectors/processes.rb', line 151 def recent_cpu_percentage @recent_cpu_percentage end |
Instance Method Details
#combined_cpu ⇒ Object
156 157 158 159 160 161 |
# File 'lib/server_metrics/collectors/processes.rb', line 156 def combined_cpu # best thread I've seen on cutime vs utime & cstime vs stime: https://www.ruby-forum.com/topic/93176 # * cutime and cstime include CPUusage of child processes # * utime and stime don't include CPU usage of child processes (utime || 0) + (stime || 0) # utime and stime aren't available on mac. Result is %cpu is 0 on mac. end |