update
This commit is contained in:
parent
c4c1a5deba
commit
616e76c4f0
@ -4,9 +4,14 @@ class NodeController < ApplicationController
|
||||
@hosts = Array.new
|
||||
@nodes = Node.all.order("id asc")
|
||||
|
||||
@node_connect = Hash.new
|
||||
@node_info = Array.new
|
||||
@node_connects = Array.new
|
||||
node_info = Hash.new
|
||||
one_node = Node.take
|
||||
|
||||
node_info["Hostname"] = one_node.host_name
|
||||
node_info["State"] = "Peer in Cluster Disconnected"
|
||||
node_info = Hash.new
|
||||
|
||||
if !one_node.blank?
|
||||
if ping_test?(one_node.host_ip)
|
||||
command = String.new
|
||||
@ -14,18 +19,51 @@ class NodeController < ApplicationController
|
||||
puts command
|
||||
output = `#{command}`.split("\n")
|
||||
output << "\n"
|
||||
|
||||
output.each do |t|
|
||||
next if t.equal? output.first
|
||||
if t.include? ":"
|
||||
temp = t.split(":")
|
||||
@node_info << temp[1]
|
||||
node_info[temp[0]] = temp[1]
|
||||
else
|
||||
@node_connect[one_node.id] << @node_info
|
||||
@node_info = Array.new
|
||||
@node_connects << node_info
|
||||
node_info = Hash.new
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
volumes = Array.new
|
||||
volume = Hash.new
|
||||
node = Node.take
|
||||
df = get_df
|
||||
# error check : node is nil
|
||||
if node.nil?
|
||||
return volumes
|
||||
end
|
||||
command = String.new
|
||||
command << "sshpass -p#{node.user_password} ssh #{node.user_name}@#{node.host_ip} gluster volume info"
|
||||
puts command
|
||||
output = `#{command}`.split("\n")
|
||||
output << "\n"
|
||||
output.each do |t|
|
||||
next if t.equal? output.first
|
||||
if t.include? ":"
|
||||
temp = t.split(":")
|
||||
volume[temp[0]] = temp[1]
|
||||
else
|
||||
volume['Mount State'] = "unmounted"
|
||||
df.each do |u|
|
||||
next if !u['Filesystem'].include? volume['Volume Name'].delete(' ')
|
||||
volume['Mount State'] = "mounted"
|
||||
volume['Mount Point'] = u['Mounted on']
|
||||
end
|
||||
volumes << volume
|
||||
volume = Hash.new
|
||||
end
|
||||
end
|
||||
return volumes
|
||||
|
||||
|
||||
if get_hosts.blank?
|
||||
flash[:danger] = "Check Server"
|
||||
|
Loading…
Reference in New Issue
Block a user