Class: ElasticAPM::Metrics::CpuMem::Linux::ProcStat Private
- Inherits:
-
Object
- Object
- ElasticAPM::Metrics::CpuMem::Linux::ProcStat
- Defined in:
- lib/elastic_apm/metrics/cpu_mem.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #total ⇒ Object readonly private
- #usage ⇒ Object readonly private
Instance Method Summary collapse
-
#read! ⇒ Object
private
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Instance Attribute Details
#total ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
125 126 127 |
# File 'lib/elastic_apm/metrics/cpu_mem.rb', line 125 def total @total end |
#usage ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
125 126 127 |
# File 'lib/elastic_apm/metrics/cpu_mem.rb', line 125 def usage @usage end |
Instance Method Details
#read! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/elastic_apm/metrics/cpu_mem.rb', line 128 def read! stat = IO.readlines('/proc/stat') .lazy .find { |sp| sp.start_with?('cpu ') } .split .map(&:to_i)[1..-1] user, nice, system, idle, iowait, irq, softirq, steal, _guest, _guest_nice = stat @total = user + nice + system + idle + iowait + irq + softirq + steal @usage = @total - (idle + iowait) self end |