class ForemanMaintain::Utils::Disk::IODevice
Attributes
dir[RW]
Public Class Methods
new(dir)
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 9 def initialize(dir) @dir = dir end
Public Instance Methods
available_space()
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 21 def available_space convert_kb_to_mb(execute!("df #{dir}|awk {'print $4'}|tail -1").to_i) end
read_speed()
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 13 def read_speed @read_speed ||= convert_kb_to_mb(fio) end
space_used()
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 29 def space_used convert_kb_to_mb(execute!("du -ks #{dir} | awk {'print $1'}").to_i) end
space_used_in_percent()
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 25 def space_used_in_percent execute!("df #{dir}|awk {'print $5'}|tail -1").to_i end
unit()
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 17 def unit @unit ||= 'MB/sec' end
Private Instance Methods
convert_kb_to_mb(val)
click to toggle source
# File lib/foreman_maintain/utils/disk/io_device.rb, line 44 def convert_kb_to_mb(val) val / 1024 end
fio()
click to toggle source
In fio command, –direct option bypass the cache page
# File lib/foreman_maintain/utils/disk/io_device.rb, line 36 def fio cmd = "fio --name=job1 --rw=read --size=1g --output-format=json\ --directory=#{dir} --direct=1 --unlink=1" stdout = execute(cmd) output = JSON.parse(stdout) @fio ||= output['jobs'].first['read']['bw'].to_i end