This commit is contained in:
kyg516 2016-09-30 18:30:56 +09:00
commit a37d4b6051
2 changed files with 33 additions and 2 deletions

View File

@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base
include ApplicationHelper include ApplicationHelper
include HomeHelper include HomeHelper
include VolumeHelper include VolumeHelper
include NodeHelper
def require_login def require_login
unless user_signed_in? unless user_signed_in?
@ -12,5 +13,4 @@ class ApplicationController < ActionController::Base
redirect_to "/users/sign_in" # halts request cycle redirect_to "/users/sign_in" # halts request cycle
end end
end end
end end

View File

@ -3,6 +3,37 @@ class NodeController < ApplicationController
def index def index
@hosts = Array.new @hosts = Array.new
@nodes = Node.all.order("id asc") @nodes = Node.all.order("id asc")
@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
command << "sshpass -p#{one_node.user_password} ssh #{one_node.user_name}@#{one_node.host_ip} gluster peer status 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(":")
node_info[temp[0]] = temp[1]
else
@node_connects << node_info
node_info = Hash.new
end
end
end
end
if get_hosts.blank? if get_hosts.blank?
flash[:danger] = "Check Server" flash[:danger] = "Check Server"
else else