Commit 7dbc3d97 authored by Josh Frye's avatar Josh Frye

Catch permission denied errors and ignore the disk

parent 6e82c0e0
class Admin::SystemInfoController < Admin::ApplicationController class Admin::SystemInfoController < Admin::ApplicationController
def show EXCLUDED_MOUNT_OPTIONS = [
excluded_mounts = [ 'nobrowse',
"nobrowse", 'read-only',
"read-only", 'ro'
"ro" ]
EXCLUDED_MOUNT_TYPES = [
'autofs',
'binfmt_misc',
'cgroup',
'debugfs',
'devfs',
'devpts',
'devtmpfs',
'efivarfs',
'fuse.gvfsd-fuse',
'fuseblk',
'fusectl',
'hugetlbfs',
'mqueue',
'proc',
'pstore',
'securityfs',
'sysfs',
'tmpfs',
'tracefs',
'vfat'
] ]
def show
system_info = Vmstat.snapshot system_info = Vmstat.snapshot
mounts = Sys::Filesystem.mounts mounts = Sys::Filesystem.mounts
@disks = [] @disks = []
mounts.each do |mount| mounts.each do |mount|
options = mount.options.split(', ') mount_options = mount.options.split(',')
next unless excluded_mounts.each { |em| break if options.include?(em) } next if (EXCLUDED_MOUNT_OPTIONS & mount_options).any?
next if (EXCLUDED_MOUNT_TYPES & [mount.mount_type]).any?
begin
disk = Sys::Filesystem.stat(mount.mount_point) disk = Sys::Filesystem.stat(mount.mount_point)
@disks.push({ @disks.push({
bytes_total: disk.bytes_total, bytes_total: disk.bytes_total,
...@@ -22,6 +47,8 @@ class Admin::SystemInfoController < Admin::ApplicationController ...@@ -22,6 +47,8 @@ class Admin::SystemInfoController < Admin::ApplicationController
disk_name: mount.name, disk_name: mount.name,
mount_path: disk.path mount_path: disk.path
}) })
rescue Sys::Filesystem::Error
end
end end
@cpus = system_info.cpus.length @cpus = system_info.cpus.length
......
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