2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
class Admin::SystemInfoController < Admin::ApplicationController
|
2022-06-21 17:19:12 +05:30
|
|
|
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
EXCLUDED_MOUNT_OPTIONS = %w[
|
|
|
|
nobrowse
|
|
|
|
read-only
|
|
|
|
ro
|
2017-08-17 22:00:37 +05:30
|
|
|
].freeze
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
EXCLUDED_MOUNT_TYPES = [
|
|
|
|
'autofs',
|
|
|
|
'binfmt_misc',
|
2022-08-13 15:12:31 +05:30
|
|
|
'bpf',
|
2016-08-24 12:49:21 +05:30
|
|
|
'cgroup',
|
2022-08-13 15:12:31 +05:30
|
|
|
'cgroup2',
|
|
|
|
'configfs',
|
2016-08-24 12:49:21 +05:30
|
|
|
'debugfs',
|
|
|
|
'devfs',
|
|
|
|
'devpts',
|
|
|
|
'devtmpfs',
|
|
|
|
'efivarfs',
|
|
|
|
'fuse.gvfsd-fuse',
|
|
|
|
'fuseblk',
|
|
|
|
'fusectl',
|
|
|
|
'hugetlbfs',
|
|
|
|
'mqueue',
|
|
|
|
'proc',
|
|
|
|
'pstore',
|
2017-08-17 22:00:37 +05:30
|
|
|
'rpc_pipefs',
|
2016-08-24 12:49:21 +05:30
|
|
|
'securityfs',
|
|
|
|
'sysfs',
|
|
|
|
'tmpfs',
|
|
|
|
'tracefs',
|
|
|
|
'vfat'
|
2017-08-17 22:00:37 +05:30
|
|
|
].freeze
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
def show
|
2022-08-27 11:52:29 +05:30
|
|
|
@cpus = begin
|
|
|
|
Vmstat.cpu
|
|
|
|
rescue StandardError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
@memory = begin
|
|
|
|
Vmstat.memory
|
|
|
|
rescue StandardError
|
|
|
|
nil
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
mounts = Sys::Filesystem.mounts
|
|
|
|
|
|
|
|
@disks = []
|
|
|
|
mounts.each do |mount|
|
|
|
|
mount_options = mount.options.split(',')
|
|
|
|
|
|
|
|
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)
|
|
|
|
@disks.push({
|
2023-03-04 22:38:38 +05:30
|
|
|
bytes_total: disk.bytes_total,
|
|
|
|
bytes_used: disk.bytes_used,
|
|
|
|
disk_name: mount.name,
|
|
|
|
mount_path: disk.path
|
|
|
|
})
|
2016-08-24 12:49:21 +05:30
|
|
|
rescue Sys::Filesystem::Error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|