From c4c1a5deba37f4242dc71031e7574ec382f6e56a Mon Sep 17 00:00:00 2001 From: bee0005 Date: Thu, 29 Sep 2016 09:35:57 +0000 Subject: [PATCH] update nodes --- app/controllers/application_controller.rb | 2 +- app/controllers/node_controller.rb | 26 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 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..f72f91a 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -2,7 +2,31 @@ 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_connect = Hash.new + @node_info = Array.new + one_node = Node.take + 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[1] + else + @node_connect[one_node.id] << @node_info + @node_info = Array.new + end + end + end + end + if get_hosts.blank? flash[:danger] = "Check Server" else