Update top, footer

This commit is contained in:
kyg516
2016-09-23 18:28:53 +09:00
parent a4c983a7e0
commit eb8e6a64b4
10 changed files with 659 additions and 740 deletions

View File

@@ -1,2 +1,52 @@
module ApplicationHelper
def get_conf
config = Hash.new
one_node = Node.take
if !one_node.nil?
config["host_name"] = one_node.host_name
config["host_ip"] = one_node.host_ip
config["user_name"] = one_node.user_name
config["user_password"] = one_node.user_password
end
return config
end
def get_conf_all
config = Array.new
config_each = Hash.new
all_node = Node.all
all_node.each do |one_node|
config_each["host_name"] = one_node.host_name
config_each["host_ip"] = one_node.host_ip
config_each["user_name"] = one_node.user_name
config_each["user_password"] = one_node.user_password
config << config_each
config_each = Hash.new
end
return config
end
def get_df
df = Array.new
df_each = Hash.new
command = String.new
command << "df -hP"
puts command
output = `#{command}`.split("\n")
output.each do |t|
next if t.equal? output.first
s = t.split(' ')
df_each['Filesystem'] = s[0]
df_each['Size'] = s[1]
df_each['Used'] = s[2]
df_each['Avail'] = s[3]
df_each['Use%'] = s[4]
df_each['Mounted on'] = s[5]
df << df_each
df_each = Hash.new
end
return df
end
end

View File

@@ -1,43 +1,28 @@
module VolumeHelper
def get_conf
@config = Hash.new
one_node = Node.take
if !one_node.nil?
@config["host_name"] = one_node.host_name
@config["host_ip"] = one_node.host_ip
@config["user_name"] = one_node.user_name
@config["user_password"] = one_node.user_password
end
return @config
end
def get_volumes
def volumes
volumes = Array.new
volume = Hash.new
command = "df -P"
df = `#{command}`
conf = get_conf
command = "sshpass -p#{conf['user_password']} ssh #{conf['user_name']}@#{conf['host_ip']} gluster volume info"
info = `#{command}`.split("\n")
info << "\n"
info.each do |t|
next if t.equal? info.first
df = get_df
command = String.new
command << "sshpass -p#{conf['user_password']} "
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
command << "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
String state = (df.include? volume['Volume Name'].delete(' ')) ? "mounted" : "unmounted"
volume['Mount State'] = state
if state.eql? "mounted"
s = df.split("\n")
s.each do |t|
if t.include? volume['Volume Name'].delete(' ')
mnt_point = t.split(" ")[5]
volume['Mount Point'] = mnt_point
end
end
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
@@ -47,8 +32,7 @@ module VolumeHelper
end
def volume_info(volume)
params = ['Type', 'Volume ID', 'Status', 'Number of Bricks', 'Transport-type',
'Bricks', 'Options Reconfigured', 'Mount State', 'Mount Point']
params = ['Type', 'Volume ID', 'Status', 'Number of Bricks', 'Transport-type', 'Bricks', 'Options Reconfigured', 'Mount State', 'Mount Point']
html = ''
html << "<div>"
params.each do |t|