104 lines
3.2 KiB
Diff
104 lines
3.2 KiB
Diff
diff --git a/Gemfile.orig b/Gemfile
|
|
index c1e9e34..a4448b7 100644
|
|
--- a/Gemfile.orig
|
|
+++ b/Gemfile
|
|
@@ -525,7 +525,6 @@ gem 'health_check', '~> 3.0' # rubocop:todo Gemfile/MissingFeatureCategory
|
|
|
|
# System information
|
|
gem 'vmstat', '~> 2.3.0' # rubocop:todo Gemfile/MissingFeatureCategory
|
|
-gem 'sys-filesystem', '~> 1.4.3' # rubocop:todo Gemfile/MissingFeatureCategory
|
|
|
|
# NTP client
|
|
gem 'net-ntp' # rubocop:todo Gemfile/MissingFeatureCategory
|
|
diff --git a/Gemfile.lock.orig b/Gemfile.lock
|
|
index e2ebb91..39b6df3 100644
|
|
--- a/Gemfile.lock.orig
|
|
+++ b/Gemfile.lock
|
|
@@ -1605,8 +1605,6 @@ GEM
|
|
attr_required (>= 0.0.5)
|
|
httpclient (>= 2.4)
|
|
sync (0.5.0)
|
|
- sys-filesystem (1.4.3)
|
|
- ffi (~> 1.1)
|
|
sysexits (1.2.0)
|
|
table_print (1.5.7)
|
|
tanuki_emoji (0.9.0)
|
|
@@ -2061,7 +2059,6 @@ DEPENDENCIES
|
|
ssh_data (~> 1.3)
|
|
stackprof (~> 0.2.25)
|
|
state_machines-activerecord (~> 0.8.0)
|
|
- sys-filesystem (~> 1.4.3)
|
|
tanuki_emoji (~> 0.9)
|
|
telesignenterprise (~> 2.2)
|
|
terser (= 1.0.2)
|
|
diff --git a/app/controllers/admin/system_info_controller.rb.orig b/app/controllers/admin/system_info_controller.rb
|
|
index 96fb73c..7b8435e 100644
|
|
--- a/app/controllers/admin/system_info_controller.rb.orig
|
|
+++ b/app/controllers/admin/system_info_controller.rb
|
|
@@ -1,4 +1,5 @@
|
|
# frozen_string_literal: true
|
|
+require 'open3'
|
|
|
|
class Admin::SystemInfoController < Admin::ApplicationController
|
|
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
|
|
@@ -36,6 +37,11 @@ class Admin::SystemInfoController < Admin::ApplicationController
|
|
'vfat'
|
|
].freeze
|
|
|
|
+ MOUNT_REGEX = /(\S+) on (\S+) type (\S+) \(([^)]+)\)/
|
|
+
|
|
+ Mount = Struct.new('Mount', :name, :mount_point, :mount_type, :options)
|
|
+ FsStat = Struct.new('FsStats', :path, :bytes_total, :bytes_used)
|
|
+
|
|
def show
|
|
@cpus = begin
|
|
Vmstat.cpu
|
|
@@ -47,7 +53,6 @@ def show
|
|
rescue StandardError
|
|
nil
|
|
end
|
|
- mounts = Sys::Filesystem.mounts
|
|
|
|
@disks = []
|
|
mounts.each do |mount|
|
|
@@ -57,15 +62,38 @@ def show
|
|
next if (EXCLUDED_MOUNT_TYPES & [mount.mount_type]).any?
|
|
|
|
begin
|
|
- disk = Sys::Filesystem.stat(mount.mount_point)
|
|
+ disk = fs_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
|
|
+ rescue IOError
|
|
end
|
|
end
|
|
end
|
|
+
|
|
+ def mounts
|
|
+ stdout, stderr, status = Open3.capture3('mount')
|
|
+ fail IOError, stderr unless status.success?
|
|
+
|
|
+ stdout.lines
|
|
+ .map { |line| MOUNT_REGEX.match(line) }
|
|
+ .compact
|
|
+ .map { |match| Mount.new(*match.captures) }
|
|
+ end
|
|
+
|
|
+ def fs_stat(mount_point)
|
|
+ stdout, status = Open3.capture2('stat', '-c', '%s %b %a', '-f', mount_point)
|
|
+ fail IOError unless status.success?
|
|
+
|
|
+ block_size, blocks_total, blocks_free = stdout.split(' ').map(&:to_i)
|
|
+
|
|
+ bytes_total = blocks_total * block_size
|
|
+ bytes_free = blocks_free * block_size
|
|
+ bytes_used = bytes_total - bytes_free
|
|
+
|
|
+ FsStat.new(mount_point, bytes_total, bytes_used)
|
|
+ end
|
|
end
|