summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Frye <joshfng@gmail.com>2016-06-29 02:04:57 +0000
committerJosh Frye <joshfng@gmail.com>2016-06-29 02:04:57 +0000
commitd171ff17beb82c2378c1eae52dada91481a48239 (patch)
treeab4ea61be9a5b6fe6b6ab8b3d3651f5cc910fecb
parentebe21acc2a2f0a569e1e10314ac9407024becafb (diff)
parentd3d11e2ae70f86333b7f1bdcb5e21f8900631161 (diff)
downloadgitlab-ce-d171ff17beb82c2378c1eae52dada91481a48239.tar.gz
Merge branch 'system-info' into 'master'
Show basic system info on admin panel. Closes #18886 ![Screen_Shot_2016-06-23_at_10.57.07_AM](/uploads/df33bc3dc36ceaf86f5e479ca15b83f3/Screen_Shot_2016-06-23_at_10.57.07_AM.png) See merge request !4858
-rw-r--r--CHANGELOG1
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock2
-rw-r--r--app/controllers/admin/system_info_controller.rb13
-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--app/views/layouts/nav/_admin.html.haml4
-rw-r--r--config/routes.rb1
-rw-r--r--spec/features/admin/admin_system_info_spec.rb17
9 files changed, 65 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 05566f36338..979c9e6e30d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@ v 8.10.0 (unreleased)
- Remove unused front-end variable -> default_issues_tracker
- Add API endpoint for a group issues !4520 (mahcsig)
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
+ - Add basic system information like memory and disk usage to the admin panel
v 8.9.3 (unreleased)
- Decreased min width of screen to 1280px for pinned sidebar
diff --git a/Gemfile b/Gemfile
index 7228decf680..a2386770992 100644
--- a/Gemfile
+++ b/Gemfile
@@ -346,3 +346,6 @@ gem "paranoia", "~> 2.0"
# Health check
gem 'health_check', '~> 1.5.1'
+
+# System information
+gem 'vmstat', '~> 2.1.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 66660f546e7..c1d2f1fdf5a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -780,6 +780,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)
@@ -984,6 +985,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..3c67370b667
--- /dev/null
+++ b/app/controllers/admin/system_info_controller.rb
@@ -0,0 +1,13 @@
+class Admin::SystemInfoController < Admin::ApplicationController
+ def show
+ system_info = Vmstat.snapshot
+
+ @cpus = system_info.cpus.length
+
+ @mem_used = system_info.memory.active_bytes
+ @mem_total = system_info.memory.total_bytes
+
+ @disk_used = system_info.disks[0].used_bytes
+ @disk_total = system_info.disks[0].total_bytes
+ end
+end
diff --git a/app/views/admin/background_jobs/_head.html.haml b/app/views/admin/background_jobs/_head.html.haml
index d78682532ed..9d722bd7382 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..3ef2f20b589
--- /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) }
+ .prepend-top-default
+ .row
+ .col-sm-4
+ .light-well
+ %h4 CPU
+ .data
+ %h1= "#{@cpus} cores"
+ .col-sm-4
+ .light-well
+ %h4 Memory
+ .data
+ %h1= "#{number_to_human_size(@mem_used)} / #{number_to_human_size(@mem_total)}"
+ .col-sm-4
+ .light-well
+ %h4 Disk
+ .data
+ %h1= "#{number_to_human_size(@disk_used)} / #{number_to_human_size(@disk_total)}"
diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml
index a7415507c8f..5ee8772882e 100644
--- a/app/views/layouts/nav/_admin.html.haml
+++ b/app/views/layouts/nav/_admin.html.haml
@@ -9,8 +9,8 @@
= link_to admin_root_path, title: 'Overview', class: 'shortcuts-tree' do
%span
Overview
- = nav_link(controller: %w(background_jobs logs health_check)) do
- = link_to admin_background_jobs_path, title: 'Monitoring' do
+ = nav_link(controller: %w(system_info background_jobs logs health_check)) do
+ = link_to admin_system_info_path, title: 'Monitoring' do
%span
Monitoring
= nav_link(controller: :broadcast_messages) do
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
diff --git a/spec/features/admin/admin_system_info_spec.rb b/spec/features/admin/admin_system_info_spec.rb
new file mode 100644
index 00000000000..dbc1d829b67
--- /dev/null
+++ b/spec/features/admin/admin_system_info_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe 'Admin System Info' do
+ before do
+ login_as :admin
+ end
+
+ describe 'GET /admin/system_info' do
+ it 'shows system info page' do
+ visit admin_system_info_path
+
+ expect(page).to have_content 'CPU'
+ expect(page).to have_content 'Memory'
+ expect(page).to have_content 'Disk'
+ end
+ end
+end