Commit 1c2e7af6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'issue-18886' into 'master'

Loop all disks when displaying system info. Closes #18886



See merge request !4983
parents 8b675291 98238a27
...@@ -349,3 +349,4 @@ gem 'health_check', '~> 1.5.1' ...@@ -349,3 +349,4 @@ gem 'health_check', '~> 1.5.1'
# System information # System information
gem 'vmstat', '~> 2.1.0' gem 'vmstat', '~> 2.1.0'
gem 'sys-filesystem', '~> 1.1.6'
...@@ -715,6 +715,8 @@ GEM ...@@ -715,6 +715,8 @@ GEM
activerecord (>= 4.1, < 5.1) activerecord (>= 4.1, < 5.1)
state_machines-activemodel (>= 0.3.0) state_machines-activemodel (>= 0.3.0)
stringex (2.5.2) stringex (2.5.2)
sys-filesystem (1.1.6)
ffi
systemu (2.6.5) systemu (2.6.5)
task_list (1.0.2) task_list (1.0.2)
html-pipeline html-pipeline
...@@ -966,6 +968,7 @@ DEPENDENCIES ...@@ -966,6 +968,7 @@ DEPENDENCIES
spring-commands-teaspoon (~> 0.0.2) spring-commands-teaspoon (~> 0.0.2)
sprockets (~> 3.6.0) sprockets (~> 3.6.0)
state_machines-activerecord (~> 0.4.0) state_machines-activerecord (~> 0.4.0)
sys-filesystem (~> 1.1.6)
task_list (~> 1.0.2) task_list (~> 1.0.2)
teaspoon (~> 1.1.0) teaspoon (~> 1.1.0)
teaspoon-jasmine (~> 2.2.0) teaspoon-jasmine (~> 2.2.0)
......
class Admin::SystemInfoController < Admin::ApplicationController class Admin::SystemInfoController < Admin::ApplicationController
def show def show
excluded_mounts = [
"nobrowse",
"read-only",
"ro"
]
system_info = Vmstat.snapshot system_info = Vmstat.snapshot
mounts = Sys::Filesystem.mounts
@disks = []
mounts.each do |mount|
options = mount.options.split(', ')
next unless excluded_mounts.each { |em| break if options.include?(em) }
disk = Sys::Filesystem.stat(mount.mount_point)
@disks.push({
bytes_total: disk.bytes_total,
bytes_used: disk.bytes_used,
disk_name: mount.name,
mount_path: disk.path
})
end
@cpus = system_info.cpus.length @cpus = system_info.cpus.length
@mem_used = system_info.memory.active_bytes @mem_used = system_info.memory.active_bytes
@mem_total = system_info.memory.total_bytes @mem_total = system_info.memory.total_bytes
@disk_used = system_info.disks[0].used_bytes
@disk_total = system_info.disks[0].total_bytes
end end
end end
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
%h1= "#{number_to_human_size(@mem_used)} / #{number_to_human_size(@mem_total)}" %h1= "#{number_to_human_size(@mem_used)} / #{number_to_human_size(@mem_total)}"
.col-sm-4 .col-sm-4
.light-well .light-well
%h4 Disk %h4 Disks
.data .data
%h1= "#{number_to_human_size(@disk_used)} / #{number_to_human_size(@disk_total)}" - @disks.each do |disk|
%h1= "#{number_to_human_size(disk[:bytes_used])} / #{number_to_human_size(disk[:bytes_total])}"
%p= "#{disk[:disk_name]}"
%p= "#{disk[:mount_path]}"
...@@ -181,3 +181,9 @@ ...@@ -181,3 +181,9 @@
:why: Equivalent to LGPLv2 :why: Equivalent to LGPLv2
:versions: [] :versions: []
:when: 2016-06-07 17:14:10.907682000 Z :when: 2016-06-07 17:14:10.907682000 Z
- - :whitelist
- Artistic 2.0
- :who: Josh Frye
:why: Disk/mount information display on Admin pages
:versions: []
:when: 2016-06-29 16:32:45.432113000 Z
...@@ -11,7 +11,7 @@ describe 'Admin System Info' do ...@@ -11,7 +11,7 @@ describe 'Admin System Info' do
expect(page).to have_content 'CPU' expect(page).to have_content 'CPU'
expect(page).to have_content 'Memory' expect(page).to have_content 'Memory'
expect(page).to have_content 'Disk' expect(page).to have_content 'Disks'
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment