Class: ElasticAPM::Metrics::CpuMemSet::Linux::Meminfo Private
- Inherits:
-
Object
- Object
- ElasticAPM::Metrics::CpuMemSet::Linux::Meminfo
- Defined in:
- lib/elastic_apm/metrics/cpu_mem_set.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
- #available ⇒ Object readonly private
- #page_size ⇒ Object readonly private
- #total ⇒ Object readonly private
Instance Method Summary collapse
-
#read! ⇒ Object
private
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity.
Instance Attribute Details
#available ⇒ 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.
216 217 218 |
# File 'lib/elastic_apm/metrics/cpu_mem_set.rb', line 216 def available @available end |
#page_size ⇒ 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.
216 217 218 |
# File 'lib/elastic_apm/metrics/cpu_mem_set.rb', line 216 def page_size @page_size end |
#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.
216 217 218 |
# File 'lib/elastic_apm/metrics/cpu_mem_set.rb', line 216 def total @total 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/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/elastic_apm/metrics/cpu_mem_set.rb', line 220 def read! # rubocop:disable Style/RescueModifier @page_size = `getconf PAGESIZE`.chomp.to_i rescue 4096 # rubocop:enable Style/RescueModifier info = IO.readlines('/proc/meminfo') .lazy .each_with_object({}) do |line, hsh| if line.start_with?('MemTotal:') hsh[:total] = line.split[1].to_i * 1024 elsif line.start_with?('MemAvailable:') hsh[:available] = line.split[1].to_i * 1024 elsif line.start_with?('MemFree:') hsh[:free] = line.split[1].to_i * 1024 elsif line.start_with?('Buffers:') hsh[:buffers] = line.split[1].to_i * 1024 elsif line.start_with?('Cached:') hsh[:cached] = line.split[1].to_i * 1024 end break hsh if hsh[:total] && hsh[:available] end @total = info[:total] @available = info[:available] || info[:free] + info[:buffers] + info[:cached] self end |