2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 10:43:28 -04:00
|
|
|
class Admin::SystemInfoController < Admin::ApplicationController
|
2022-04-05 08:10:23 -04:00
|
|
|
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
|
2020-10-05 17:08:47 -04:00
|
|
|
|
2019-12-20 04:24:38 -05:00
|
|
|
EXCLUDED_MOUNT_OPTIONS = %w[
|
|
|
|
nobrowse
|
|
|
|
read-only
|
|
|
|
ro
|
2017-02-21 18:32:18 -05:00
|
|
|
].freeze
|
2016-06-30 09:47:24 -04:00
|
|
|
|
|
|
|
EXCLUDED_MOUNT_TYPES = [
|
|
|
|
'autofs',
|
|
|
|
'binfmt_misc',
|
2022-06-29 17:09:23 -04:00
|
|
|
'bpf',
|
2016-06-30 09:47:24 -04:00
|
|
|
'cgroup',
|
2022-06-29 17:09:23 -04:00
|
|
|
'cgroup2',
|
|
|
|
'configfs',
|
2016-06-30 09:47:24 -04:00
|
|
|
'debugfs',
|
|
|
|
'devfs',
|
|
|
|
'devpts',
|
|
|
|
'devtmpfs',
|
|
|
|
'efivarfs',
|
|
|
|
'fuse.gvfsd-fuse',
|
|
|
|
'fuseblk',
|
|
|
|
'fusectl',
|
|
|
|
'hugetlbfs',
|
|
|
|
'mqueue',
|
|
|
|
'proc',
|
|
|
|
'pstore',
|
2017-02-18 04:39:49 -05:00
|
|
|
'rpc_pipefs',
|
2016-06-30 09:47:24 -04:00
|
|
|
'securityfs',
|
|
|
|
'sysfs',
|
|
|
|
'tmpfs',
|
|
|
|
'tracefs',
|
|
|
|
'vfat'
|
2017-02-21 18:32:18 -05:00
|
|
|
].freeze
|
2016-06-28 22:30:01 -04:00
|
|
|
|
2016-06-30 09:47:24 -04:00
|
|
|
def show
|
2016-08-24 13:06:19 -04:00
|
|
|
@cpus = Vmstat.cpu rescue nil
|
|
|
|
@memory = Vmstat.memory rescue nil
|
2016-06-28 22:30:01 -04:00
|
|
|
mounts = Sys::Filesystem.mounts
|
|
|
|
|
|
|
|
@disks = []
|
|
|
|
mounts.each do |mount|
|
2016-06-30 09:47:24 -04:00
|
|
|
mount_options = mount.options.split(',')
|
2016-06-28 22:30:01 -04:00
|
|
|
|
2016-06-30 09:47:24 -04:00
|
|
|
next if (EXCLUDED_MOUNT_OPTIONS & mount_options).any?
|
|
|
|
next if (EXCLUDED_MOUNT_TYPES & [mount.mount_type]).any?
|
2016-06-28 22:30:01 -04:00
|
|
|
|
2016-06-30 09:47:24 -04:00
|
|
|
begin
|
|
|
|
disk = Sys::Filesystem.stat(mount.mount_point)
|
|
|
|
@disks.push({
|
2016-06-28 22:30:01 -04:00
|
|
|
bytes_total: disk.bytes_total,
|
2022-08-03 20:08:55 -04:00
|
|
|
bytes_used: disk.bytes_used,
|
|
|
|
disk_name: mount.name,
|
|
|
|
mount_path: disk.path
|
2016-06-30 09:47:24 -04:00
|
|
|
})
|
|
|
|
rescue Sys::Filesystem::Error
|
|
|
|
end
|
2016-06-28 22:30:01 -04:00
|
|
|
end
|
2016-06-22 10:43:28 -04:00
|
|
|
end
|
|
|
|
end
|