\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/ohai-16.3.2/lib/ohai/plugins/linux/

Viewing File: memory.rb

#
# Author:: Adam Jacob (<adam@chef.io>)
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

Ohai.plugin(:Memory) do
  provides "memory", "memory/swap"

  collect_data(:linux) do
    memory Mash.new
    memory[:swap] = Mash.new
    memory[:hugepages] = Mash.new
    memory[:directmap] = Mash.new

    File.open("/proc/meminfo").each do |line|
      case line
      when /^MemTotal:\s+(\d+) (.+)$/
        memory[:total] = "#{$1}#{$2}"
      when /^MemFree:\s+(\d+) (.+)$/
        memory[:free] = "#{$1}#{$2}"
      when /^MemAvailable:\s+(\d+) (.+)$/
        memory[:available] = "#{$1}#{$2}"
      when /^Buffers:\s+(\d+) (.+)$/
        memory[:buffers] = "#{$1}#{$2}"
      when /^Cached:\s+(\d+) (.+)$/
        memory[:cached] = "#{$1}#{$2}"
      when /^Active:\s+(\d+) (.+)$/
        memory[:active] = "#{$1}#{$2}"
      when /^Inactive:\s+(\d+) (.+)$/
        memory[:inactive] = "#{$1}#{$2}"
      when /^HighTotal:\s+(\d+) (.+)$/
        memory[:high_total] = "#{$1}#{$2}"
      when /^HighFree:\s+(\d+) (.+)$/
        memory[:high_free] = "#{$1}#{$2}"
      when /^LowTotal:\s+(\d+) (.+)$/
        memory[:low_total] = "#{$1}#{$2}"
      when /^LowFree:\s+(\d+) (.+)$/
        memory[:low_free] = "#{$1}#{$2}"
      when /^Dirty:\s+(\d+) (.+)$/
        memory[:dirty] = "#{$1}#{$2}"
      when /^Writeback:\s+(\d+) (.+)$/
        memory[:writeback] = "#{$1}#{$2}"
      when /^AnonPages:\s+(\d+) (.+)$/
        memory[:anon_pages] = "#{$1}#{$2}"
      when /^Mapped:\s+(\d+) (.+)$/
        memory[:mapped] = "#{$1}#{$2}"
      when /^Slab:\s+(\d+) (.+)$/
        memory[:slab] = "#{$1}#{$2}"
      when /^SReclaimable:\s+(\d+) (.+)$/
        memory[:slab_reclaimable] = "#{$1}#{$2}"
      when /^SUnreclaim:\s+(\d+) (.+)$/
        memory[:slab_unreclaim] = "#{$1}#{$2}"
      when /^PageTables:\s+(\d+) (.+)$/
        memory[:page_tables] = "#{$1}#{$2}"
      when /^NFS_Unstable:\s+(\d+) (.+)$/
        memory[:nfs_unstable] = "#{$1}#{$2}"
      when /^Bounce:\s+(\d+) (.+)$/
        memory[:bounce] = "#{$1}#{$2}"
      when /^CommitLimit:\s+(\d+) (.+)$/
        memory[:commit_limit] = "#{$1}#{$2}"
      when /^Committed_AS:\s+(\d+) (.+)$/
        memory[:committed_as] = "#{$1}#{$2}"
      when /^VmallocTotal:\s+(\d+) (.+)$/
        memory[:vmalloc_total] = "#{$1}#{$2}"
      when /^VmallocUsed:\s+(\d+) (.+)$/
        memory[:vmalloc_used] = "#{$1}#{$2}"
      when /^VmallocChunk:\s+(\d+) (.+)$/
        memory[:vmalloc_chunk] = "#{$1}#{$2}"
      when /^SwapCached:\s+(\d+) (.+)$/
        memory[:swap][:cached] = "#{$1}#{$2}"
      when /^SwapTotal:\s+(\d+) (.+)$/
        memory[:swap][:total] = "#{$1}#{$2}"
      when /^SwapFree:\s+(\d+) (.+)$/
        memory[:swap][:free] = "#{$1}#{$2}"
      when /^HugePages_Total:\s+(\d+)$/
        memory[:hugepages][:total] = $1.to_s
      when /^HugePages_Free:\s+(\d+)$/
        memory[:hugepages][:free] = $1.to_s
      when /^HugePages_Rsvd:\s+(\d+)$/
        memory[:hugepages][:reserved] = $1.to_s
      when /^HugePages_Surp:\s+(\d+)$/
        memory[:hugepages][:surplus] = $1.to_s
      when /^Hugepagesize:\s+(\d+) (.+)$/
        memory[:hugepage_size] = "#{$1}#{$2}"
      when /^Hugetlb:\s+(\d+) (.+)$/
        memory[:hugetlb] = "#{$1}#{$2}"
      when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)$/
        memory[:directmap][$1.to_sym] = "#{$2}#{$3}"
      end
    end
  end
end