class ForemanMaintain::Utils::Disk::Device

Constants

EXTERNAL_MOUNT_TYPE

Attributes

dir[RW]
io_device[R]
name[RW]
read_speed[RW]
unit[RW]

Public Class Methods

new(dir) click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 17
def initialize(dir)
  @dir = dir
  @name = find_device
  @io_device = init_io_device
end

Public Instance Methods

performance() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 29
def performance
  "#{read_speed} #{unit}"
end
slow_disk_error_msg() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 23
def slow_disk_error_msg
  "Slow disk detected #{dir} mounted on #{name}.
     Actual disk speed: #{read_speed} #{default_unit}
     Expected disk speed: #{expected_io} #{default_unit}."
end

Private Instance Methods

default_unit() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 52
def default_unit
  Checks::Disk::Performance::DEFAULT_UNIT
end
expected_io() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 56
def expected_io
  Checks::Disk::Performance::EXPECTED_IO
end
externally_mounted?() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 43
def externally_mounted?
  device_type = execute("stat -f -c %T #{dir}")
  EXTERNAL_MOUNT_TYPE.include?(device_type)
end
find_device() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 48
def find_device
  execute("df -h #{dir} | sed -n '2p' | awk '{print $1}'")
end
init_io_device() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 35
def init_io_device
  if externally_mounted?
    IO::FileSystem
  else
    IO::BlockDevice
  end.new(dir, name)
end