Module: Facter::Util::Resolvers::FilesystemHelper

Included in:
Resolvers::Macosx::Mountpoints, Resolvers::Mountpoints, Resolvers::Solaris::Mountpoints
Defined in:
lib/facter/util/resolvers/filesystem_helper.rb

Overview

Since:

  • 2.0.0

Constant Summary collapse

MOUNT_KEYS =

Since:

  • 2.0.0

%i[device filesystem path options
available available_bytes size
size_bytes used used_bytes capacity].freeze

Class Method Summary collapse

Class Method Details

.compute_capacity(used, total) ⇒ Object

Since:

  • 2.0.0



21
22
23
24
25
26
27
28
29
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 21

def compute_capacity(used, total)
  if used == total
    '100%'
  elsif used.positive?
    "#{format('%<value>.2f', value: (used / total.to_f * 100))}%"
  else
    '0%'
  end
end

.read_mountpoint_stats(path) ⇒ Object

Since:

  • 2.0.0



16
17
18
19
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 16

def read_mountpoint_stats(path)
  require 'sys/filesystem'
  Sys::Filesystem.stat(path)
end

.read_mountpointsObject

Since:

  • 2.0.0



11
12
13
14
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 11

def read_mountpoints
  require 'sys/filesystem'
  force_utf(Sys::Filesystem.mounts)
end