Class: DogNotGod::Commands::MemoryStats
Overview
Memory statistics, including swap
Instance Method Summary
collapse
#get_hostname_from_shell, #run!
Instance Method Details
#_execute ⇒ Object
106
107
108
|
# File 'lib/client_commands.rb', line 106
def _execute
@resource["/mem_stats"].post({:hostname => @hostname, :mem_available => @memory_stats[:mem_available], :mem_used => @memory_stats[:mem_used], :swap_available => @memory_stats[:swap_available], :swap_used => @memory_stats[:swap_used]})
end
|
#_prepare ⇒ Object
101
102
103
104
|
# File 'lib/client_commands.rb', line 101
def _prepare
@hostname = get_hostname_from_shell
@memory_stats = get_memory_and_swap_statistics_from_shell
end
|
#get_memory_and_swap_statistics_from_shell ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/client_commands.rb', line 110
def get_memory_and_swap_statistics_from_shell
mem = DogNotGod::Shell.call("free").split("\n")
mem.shift
{:mem_available => mem[0].split(" ")[3], :mem_used => mem[0].split(" ")[2], :swap_available => mem[2].split(" ")[3], :swap_used => mem[2].split(" ")[2] }
end
|