Loop all disks when displaying system info
This commit is contained in:
parent
d171ff17be
commit
98238a27c7
1
Gemfile
1
Gemfile
|
@ -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'
|
||||||
|
|
|
@ -716,6 +716,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
|
||||||
|
@ -970,6 +972,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)
|
||||||
|
|
|
@ -1,13 +1,32 @@
|
||||||
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 @@
|
||||||
%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 @@
|
||||||
: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
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue