diff options
author | Josh Frye <joshfng@gmail.com> | 2016-06-30 09:47:24 -0400 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-06-30 13:53:35 -0400 |
commit | 7dbc3d97d1b4706fa7bc92dc7f89c33e7a1cee01 (patch) | |
tree | 9a69044425c629c7417f1c680c28917bfb229cbf | |
parent | 6e82c0e06ea25d6d0871037fb09301698ca972bd (diff) | |
download | gitlab-ce-improve-system-info.tar.gz |
Catch permission denied errors and ignore the diskimprove-system-info
-rw-r--r-- | app/controllers/admin/system_info_controller.rb | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb index cc63009cdc0..e4c73008826 100644 --- a/app/controllers/admin/system_info_controller.rb +++ b/app/controllers/admin/system_info_controller.rb @@ -1,27 +1,54 @@ class Admin::SystemInfoController < Admin::ApplicationController - def show - excluded_mounts = [ - "nobrowse", - "read-only", - "ro" - ] + EXCLUDED_MOUNT_OPTIONS = [ + 'nobrowse', + 'read-only', + '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 mounts = Sys::Filesystem.mounts @disks = [] 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? - disk = Sys::Filesystem.stat(mount.mount_point) - @disks.push({ + begin + 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 - }) + }) + rescue Sys::Filesystem::Error + end end @cpus = system_info.cpus.length |