summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock4
-rw-r--r--app/controllers/admin/system_info_controller.rb12
-rw-r--r--app/views/admin/background_jobs/_head.html.haml4
-rw-r--r--app/views/admin/system_info/show.html.haml22
-rw-r--r--config/routes.rb1
6 files changed, 47 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index 7228decf680..ffc3514a198 100644
--- a/Gemfile
+++ b/Gemfile
@@ -346,3 +346,7 @@ gem "paranoia", "~> 2.0"
# Health check
gem 'health_check', '~> 1.5.1'
+
+# System information
+gem 'vmstat', '~> 2.1.0'
+gem 'filesize', '~> 0.1.1'
diff --git a/Gemfile.lock b/Gemfile.lock
index 66660f546e7..afc1dce1710 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -207,6 +207,7 @@ GEM
multi_json
ffaker (2.0.0)
ffi (1.9.10)
+ filesize (0.1.1)
flay (2.6.1)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
@@ -780,6 +781,7 @@ GEM
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
+ vmstat (2.1.0)
warden (1.2.6)
rack (>= 1.0)
web-console (2.3.0)
@@ -849,6 +851,7 @@ DEPENDENCIES
email_spec (~> 1.6.0)
factory_girl_rails (~> 4.6.0)
ffaker (~> 2.0.0)
+ filesize (~> 0.1.1)
flay
flog
fog-aws (~> 0.9)
@@ -984,6 +987,7 @@ DEPENDENCIES
unicorn-worker-killer (~> 0.4.2)
version_sorter (~> 2.0.0)
virtus (~> 1.0.1)
+ vmstat (~> 2.1.0)
web-console (~> 2.0)
webmock (~> 1.21.0)
wikicloth (= 0.8.1)
diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb
new file mode 100644
index 00000000000..a548f941dc5
--- /dev/null
+++ b/app/controllers/admin/system_info_controller.rb
@@ -0,0 +1,12 @@
+class Admin::SystemInfoController < Admin::ApplicationController
+ def show
+ system_info = Vmstat.snapshot
+ @load = system_info.load_average.collect { |v| v.round(2) }.join(', ')
+
+ @mem_used = Filesize.from("#{system_info.memory.active_bytes} B").to_s('GB')
+ @mem_total = Filesize.from("#{system_info.memory.total_bytes} B").to_s('GB')
+
+ @disk_used = Filesize.from("#{system_info.disks[0].used_bytes} B").to_s('GB')
+ @disk_total = Filesize.from("#{system_info.disks[0].total_bytes} B").to_s('GB')
+ end
+end
diff --git a/app/views/admin/background_jobs/_head.html.haml b/app/views/admin/background_jobs/_head.html.haml
index d78682532ed..5ad99a7f6e0 100644
--- a/app/views/admin/background_jobs/_head.html.haml
+++ b/app/views/admin/background_jobs/_head.html.haml
@@ -1,5 +1,9 @@
.nav-links.sub-nav
%ul{ class: (container_class) }
+ = nav_link(controller: :system_info) do
+ = link_to admin_system_info_path, title: 'System Info' do
+ %span
+ System Info
= nav_link(controller: :background_jobs) do
= link_to admin_background_jobs_path, title: 'Background Jobs' do
%span
diff --git a/app/views/admin/system_info/show.html.haml b/app/views/admin/system_info/show.html.haml
new file mode 100644
index 00000000000..01496e4fcf5
--- /dev/null
+++ b/app/views/admin/system_info/show.html.haml
@@ -0,0 +1,22 @@
+- @no_container = true
+- page_title "System Info"
+= render 'admin/background_jobs/head'
+
+%div{ class: (container_class) }
+ %p
+ .row
+ .col-sm-4
+ .light-well
+ %h4 CPU Load
+ .data
+ %h1= @load
+ .col-sm-4
+ .light-well
+ %h4 Memory
+ .data
+ %h1= "#{@mem_used} / #{@mem_total}"
+ .col-sm-4
+ .light-well
+ %h4 Disk
+ .data
+ %h1= "#{@disk_used} / #{@disk_total}"
diff --git a/config/routes.rb b/config/routes.rb
index e45293cdf7f..bdfb16a66bf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -280,6 +280,7 @@ Rails.application.routes.draw do
resource :logs, only: [:show]
resource :health_check, controller: 'health_check', only: [:show]
resource :background_jobs, controller: 'background_jobs', only: [:show]
+ resource :system_info, controller: 'system_info', only: [:show]
resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
root to: 'projects#index', as: :projects