From 6a30df406f87fe0ee47f86befa690fdf53d45ed6 Mon Sep 17 00:00:00 2001 From: kyg516 Date: Mon, 3 Oct 2016 15:56:43 +0900 Subject: [PATCH] Add volume status to home index --- app/helpers/home_helper.rb | 6 ++- app/views/home/index.html.erb | 85 ++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 8 deletions(-) diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb index b471640..4d12ede 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -96,6 +96,7 @@ module HomeHelper def html_disk_file_table(dir = @current_dir, id = "disk_file_table") html = String.new + html << "
" html << "" html << "" html << "" get_df.each_with_index do |file, index| + # show mounted files only + color = ['blue', 'green', 'red', 'purple', 'grey'][index % 5] html << "" end @@ -137,6 +140,7 @@ module HomeHelper html << "
" @@ -119,6 +120,8 @@ module HomeHelper html << "
" html << "
" @@ -128,7 +131,7 @@ module HomeHelper html << "
" html << "
" html << "

" - html << format((file["Use%"][0..file["Use%"].length - 1])) + "%" + html << file["Use%"] html << "

" html << "
" html << "" html << "" + html << "
" return html end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index d850b33..bce31ec 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -133,6 +133,7 @@ <% nodes = ssh_nodes %> + <% volumes = ssh_volume_info %>
@@ -154,7 +155,7 @@
-
+
<% ping = ((nodes.select{ |node| node["ping"].eql? "true" }.length.to_f / nodes.length.to_f) * 100).to_i %>
@@ -208,6 +209,62 @@
+ +
+
+

Volumes Status

+ +
+
+
+
+ <% start = ((volumes.select{ |volume| volume["Status"].eql? " Started" }.length.to_f / volumes.length.to_f) * 100).to_i %> +
+ started +
+
+
+
+
+
+
+
+ <%= volumes.select{ |volume| volume["Status"].eql? " Started" }.length %> / <%= volumes.length %> +
+
+
+
+ <% mount = ((volumes.select{ |volume| volume["Mount State"].eql? "mounted" }.length.to_f / volumes.length.to_f) * 100).to_i %> +
+ mounted +
+
+
+
+
+
+
+
+ <%= volumes.select{ |volume| volume["Mount State"].eql? "mounted" }.length %> / <%= volumes.length %> +
+
+
+
+
@@ -231,7 +288,7 @@
-
+
    <% nodes.each do |node| %>
  • @@ -245,10 +302,10 @@ <% end %>
    - <%= node["host_name"] %> + "><%= node["host_name"] %>

    <%= node["host_ip"] %> <%= node["user_name"] %>

    <% if node["gluster"].eql? "on" %> -

    <%= node["number_of_peers"] %>

    +

    number of peers: <%= node["number_of_peers"] %>

    <% end %>
  • @@ -261,11 +318,25 @@
    -
    +
    -

    Disk usage

    +

    Mounted usage

    + +
    -
    +
    <%= raw html_disk_file_table %>