1.use Sys::Filesystem.stat(dir) install:
gem install sys-filesystem
doc:
https://www.rubydoc.info/gems/sys-filesystem/1.1.4/Sys/Filesystem/Stat
example:
def dir_usuage_percentage dir_stat = Sys::Filesystem.stat('/motion') dir_stat.bytes_used.to_f*100 / dir_stat.bytes_total.to_f end
2. usage percentage
spaceMb_i = `df -BM /dev/sdb1`.split[10].to_i => 49
free diskspace(G)
spaceGb_i = `df -BG /dev/sdb1`.split[9].to_i => 947
O