Class: DogNotGod::Commands::DiskStats

Inherits:
ClientCommand show all
Defined in:
lib/client_commands.rb

Overview

Disk statistics

Instance Method Summary collapse

Methods inherited from ClientCommand

#get_hostname_from_shell, #run!

Instance Method Details

#_executeObject



78
79
80
81
82
# File 'lib/client_commands.rb', line 78

def _execute
  @disk_stats.each do |line|
    @resource["/file_system_stats"].post({:file_system_name => line[0], :mounted_on => line[-1], :used => line[2], :available => line[3], :hostname => @hostname})
  end
end

#_prepareObject



73
74
75
76
# File 'lib/client_commands.rb', line 73

def _prepare
  @hostname = get_hostname_from_shell
  @disk_stats = get_disk_statistics_from_shell
end

#get_disk_statistics_from_shellObject

Extract disk data from df call

  • Only extract entries for filesystems starting with a /

  • Ignore capacity % column



90
91
92
# File 'lib/client_commands.rb', line 90

def get_disk_statistics_from_shell
  DogNotGod::Shell.call("df -ak").scan(/^(\/[\w+\/-]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+\d+\%\s+(\/.*)\n/)
end