diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f54ca7..2e4f3c6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base include ApplicationHelper include HomeHelper include VolumeHelper + include NodeHelper def require_login unless user_signed_in? @@ -12,5 +13,4 @@ class ApplicationController < ActionController::Base redirect_to "/users/sign_in" # halts request cycle end end - end diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index 90fc615..778d597 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -2,7 +2,38 @@ class NodeController < ApplicationController before_action :require_login def index @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? flash[:danger] = "Check Server" else