added ebuild for gitlab-8.12.7 and incorporated the following patches from Jakub: - 0002-default-configs.patch - 0005-fix-check-task.patch - 0006-replace-sys-filesystem.patch Package-Manager: portage-2.3.0
78 lines
2.3 KiB
Diff
78 lines
2.3 KiB
Diff
diff --git a/Gemfile b/Gemfile
|
|
index 4a517b2..ed6fc2e 100644
|
|
--- a/Gemfile
|
|
+++ b/Gemfile
|
|
@@ -352,4 +352,4 @@ gem 'health_check', '~> 2.1.0'
|
|
|
|
# System information
|
|
gem 'vmstat', '~> 2.2'
|
|
-gem 'sys-filesystem', '~> 1.1.6'
|
|
+gem 'sys-filesystem', '~> 1.1.6', group: :exclude
|
|
diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb
|
|
index ca04a17..0e36b12 100644
|
|
--- a/app/controllers/admin/system_info_controller.rb
|
|
+++ b/app/controllers/admin/system_info_controller.rb
|
|
@@ -1,3 +1,5 @@
|
|
+require 'open3'
|
|
+
|
|
class Admin::SystemInfoController < Admin::ApplicationController
|
|
EXCLUDED_MOUNT_OPTIONS = [
|
|
'nobrowse',
|
|
@@ -28,10 +30,14 @@ class Admin::SystemInfoController < Admin::ApplicationController
|
|
'vfat'
|
|
]
|
|
|
|
+ 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 = Vmstat.cpu rescue nil
|
|
@memory = Vmstat.memory rescue nil
|
|
- mounts = Sys::Filesystem.mounts
|
|
|
|
@disks = []
|
|
mounts.each do |mount|
|
|
@@ -41,15 +47,38 @@ class Admin::SystemInfoController < Admin::ApplicationController
|
|
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
|