summaryrefslogtreecommitdiff
path: root/app/controllers/admin/system_info_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin/system_info_controller.rb')
-rw-r--r--app/controllers/admin/system_info_controller.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb
new file mode 100644
index 00000000000..e4c73008826
--- /dev/null
+++ b/app/controllers/admin/system_info_controller.rb
@@ -0,0 +1,59 @@
+class Admin::SystemInfoController < Admin::ApplicationController
+ 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|
+ 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({
+ 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
+
+ @mem_used = system_info.memory.active_bytes
+ @mem_total = system_info.memory.total_bytes
+ end
+end