Class: WatchmonkeyCli::Checkers::UnixMdadm
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/watchmonkey_cli/checkers/unix_mdadm.rb', line 34
def _parse_response res
return false if res.downcase["no such file"]
{ devices: [] }.tap do |r|
res = res.strip
chunks = res.split("\n").map(&:strip)
chunks.reject!{|el| el =~ /\Awarning:/i }
personalities = chunks.delete_at(chunks.index{|c| c =~ /^personalities/i })
r[:personalities] = personalities.match(/^personalities(?:\s?): (.*)$/i)[1].split(" ").map{|s| s[1..-2] }
unused_devices = chunks.delete_at(chunks.index{|c| c =~ /^unused devices/i })
r[:unused_devices] = unused_devices.match(/^unused devices\s?: (.*)$/i)[1]
chunks.join("\n").split("\n\n").map{|sp| sp.split("\n") }.each do |rdev|
r[:devices] << rdev
end
end
rescue StandardError => e
return "failed to parse mdadm output - #{e.class}: #{e.message}"
end
|
#check!(result, host, opts = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/watchmonkey_cli/checkers/unix_mdadm.rb', line 13
def check! result, host, opts = {}
result.command = "cat /proc/mdstat"
result.result = host.exec(result.command)
result.data = _parse_response(result.result)
if !result.data
result.error!(result.result)
else
result.data[:devices].each do |rdev|
dev = rdev[0].split(" ").first
status = rdev[1].split(" ").last
progress = rdev[2].to_s
return if status == "chunks"
result.error! "#{dev} seems broken (expected U+, got `#{status}')" if status !~ /\[U+\]/
if opts[:log_checking] && progress && m = progress.match(/\[[=>\.]+\]\s+([^\s]+)\s+=\s+([^\s]+)\s+\(([^\/]+)\/([^\)]+)\)\s+finish=([^\s]+)\s+speed=([^\s]+)/i)
info "#{dev} on is checking (status:#{m[1]}|done:#{m[2]}|eta:#{m[5]}|speed:#{m[6]}|blocks_done:#{m[3]}/#{m[4]})"
end
end
end
end
|
#enqueue(host, opts = {}) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/watchmonkey_cli/checkers/unix_mdadm.rb', line 6
def enqueue host, opts = {}
opts = { log_checking: true }.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
|