Commit 98238a27 authored by Josh Frye's avatar Josh Frye

Loop all disks when displaying system info

parent d171ff17
......@@ -349,3 +349,4 @@ gem 'health_check', '~> 1.5.1'
# System information
gem 'vmstat', '~> 2.1.0'
gem 'sys-filesystem', '~> 1.1.6'
......@@ -716,6 +716,8 @@ GEM
activerecord (>= 4.1, < 5.1)
state_machines-activemodel (>= 0.3.0)
stringex (2.5.2)
sys-filesystem (1.1.6)
ffi
systemu (2.6.5)
task_list (1.0.2)
html-pipeline
......@@ -970,6 +972,7 @@ DEPENDENCIES
spring-commands-teaspoon (~> 0.0.2)
sprockets (~> 3.6.0)
state_machines-activerecord (~> 0.4.0)
sys-filesystem (~> 1.1.6)
task_list (~> 1.0.2)
teaspoon (~> 1.1.0)
teaspoon-jasmine (~> 2.2.0)
......
class Admin::SystemInfoController < Admin::ApplicationController
def show
excluded_mounts = [
"nobrowse",
"read-only",
"ro"
]
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
@mem_used = system_info.memory.active_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
......@@ -17,6 +17,9 @@
%h1= "#{number_to_human_size(@mem_used)} / #{number_to_human_size(@mem_total)}"
.col-sm-4
.light-well
%h4 Disk
%h4 Disks
.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
:versions: []
: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 'Memory'
expect(page).to have_content 'Disk'
expect(page).to have_content 'Disks'
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