Class: WatchmonkeyCli::Checkers::UnixDf
Instance Attribute Summary
#app
Instance Method Summary
collapse
#_tolog, checker_name, checker_name=, #debug, descendants, #error, #info, inherited, #init, #initialize, #local, #rsafe, #safe, #spawn_sub, #start, #stop
Instance Method Details
#_parse_response(res) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/watchmonkey_cli/checkers/unix_df.rb', line 23
def _parse_response res
[].tap do |r|
res.strip.split("\n")[1..-1].each do |device|
chunks = device.split(" ")
r << {
filesystem: chunks[0],
size: chunks[1].to_i,
used: chunks[2].to_i,
available: chunks[3].to_i,
use: chunks[4].to_i,
free: 100-chunks[4].to_i,
mountpoint: chunks[5],
}
end
end
end
|
#check!(result, host, opts = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/watchmonkey_cli/checkers/unix_df.rb', line 13
def check! result, host, opts = {}
result.command = "df"
result.result = host.exec(result.command)
result.data = _parse_response(result.result)
result.data.each do |fs|
result.error! "disk space on `#{fs[:mountpoint] || "unmounted"}' (#{fs[:filesystem]}) is low (limit is min. #{opts[:min_percent]}%, got #{fs[:free]}%)" if fs[:free] < opts[:min_percent]
end if opts[:min_percent]
end
|
#enqueue(host, opts = {}) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/watchmonkey_cli/checkers/unix_df.rb', line 6
def enqueue host, opts = {}
opts = { min_percent: 25 }.merge(opts)
host = app.fetch_connection(:loopback, :local) if !host || host == :local
host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol)
app.enqueue(self, host, opts)
end
|