This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

df

Get disk usage for a filesystem in ruby.
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = host.df
result.success?
true

result[0].type
'ext4'

Parameters

Field Type Description
path string
A path of the mounted filesystem
inodes boolean
List inode information instead of block usage (capacity field)

Result

Returns an array of DiskFree structs.

DiskFree Fields

Field Type Description
file_system string Where the disk device is stored
type string Filesystem formatted partition type (ext4, xfs, fat, etc)
total integer Total disk space available for this mounted partition (in Kilobytes)
used integer Amount of disk space used in the partition (in Kilobytes)
capacity integer Either the capacity is in the number of blocks used, or number of inodes used depending on the inodes option
mount string Where the partition is mounted to

Return Example

host.df[0]
#<Struct:Kanrisuru::Core::Disk::DiskFree:0x00000dc0
  capacity = 80,
  file_system = "/dev/vda1",
  mount = "/",
  total = 7950756,
  type = "ext4",
  used = 1628860
>

Exit Status

Code Description
0 Success
1 Failure

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES