Class: Remon::Metrics::Disk

Inherits:
Object
  • Object
show all
Defined in:
lib/remon/metrics/disk.rb

Instance Method Summary collapse

Instance Method Details

#disks_usageObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/remon/metrics/disk.rb', line 5

def disks_usage
  disks = []
  IO.popen(['df', '-h']) do |io|
    io.each_line do |l|
      f = l.split(/\s+/)
      next if f[0] == 'Filesystem'
      next unless f[0] =~ /\// # Needs at least one slash in the mount path

      disk_info = {}
      disk_info[:mount] = f[5]
      disk_info[:percent] = (f[4].to_f/100).round(2)
      disk_info[:size] = f[1]
      disks << disk_info
    end
  end
  disks
end