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
Constant Summary collapse
- MOUNT_KEYS =
%i[device filesystem path options available available_bytes size size_bytes used used_bytes capacity].freeze
Class Method Summary collapse
- .compute_capacity(used, total) ⇒ Object
- .read_mountpoint_stats(path) ⇒ Object
- .read_mountpoints ⇒ Object
Class Method Details
.compute_capacity(used, total) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 23 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
18 19 20 21 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 18 def read_mountpoint_stats(path) require 'sys/filesystem' Sys::Filesystem.stat(path) end |
.read_mountpoints ⇒ Object
11 12 13 14 15 16 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 11 def read_mountpoints # TODO: this require must be replaced with "require 'sys/filesystem'" when a new release of # djberg96/sys-filesystem gem is available require_relative '../../patches/sysfilesystem/sys/statvfs.rb' force_utf(Sys::Filesystem.mounts) end |