Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F5493873
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Sep 30, 11:23 AM
Size
4 KB
Mime Type
text/x-diff
Expires
Fri, Oct 2, 11:23 AM (21 h, 44 m)
Engine
blob
Format
Raw Data
Handle
458570
Attached To
rARCHIVING archiving
View Options
diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb
index 678b1f9..3152c22 100644
--- a/app/controllers/admin/base_controller.rb
+++ b/app/controllers/admin/base_controller.rb
@@ -1,31 +1,32 @@
class Admin::BaseController < ApplicationController
before_action :require_admin, except: [:login]
# GET /admin
# POST /admin
def index
@client_ids = Client.pluck(:ClientId)
get_charts
+ @global_stats = GlobalStats.new.stats
render 'admin/index'
end
# GET /admin/login
def login
render 'admin/login'
end
protected
def get_charts
days_ago = params.fetch(:days_back, 7).to_i rescue 7
@job_status = ChartGenerator.job_statuses(@client_ids, days_ago)
@job_stats = ChartGenerator.job_stats(@client_ids, days_ago - 1)
end
def require_admin
return if current_user.try(:admin?)
flash[:alert] = 'You need to log in first'
redirect_to admin_login_path
end
end
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb
index b6ad4f1..b1f74d3 100644
--- a/app/views/admin/index.html.erb
+++ b/app/views/admin/index.html.erb
@@ -1,3 +1,12 @@
-<h1>Archiving</h1>
+<div class="row">
+ <div class="col-xs-4 text-right right">
+ <%= bootstrap_form_tag(url: admin_path, method: :post, layout: :inline) do |f| %>
+ <%= f.select(:days_back, [['1 week', 7], ['2 weeks', 14], ['1 month', 30]], selected: params[:days_back]) %>
+ <%= f.submit 'See Stats', class: "btn btn-primary" %>
+ <% end %>
+ </div>
+</div>
+
+<br />
<%= render partial: 'clients/client_graphs', locals: { path: admin_path } %>
diff --git a/app/views/clients/_client_graphs.html.erb b/app/views/clients/_client_graphs.html.erb
index 1d9fda8..c5be351 100644
--- a/app/views/clients/_client_graphs.html.erb
+++ b/app/views/clients/_client_graphs.html.erb
@@ -1,18 +1,32 @@
-<br />
<div class='row'>
+ <% if @global_stats.present? %>
+ <div class='col-xs-3'>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4>Global Stats</h4>
+ </div>
+
+ <div class="table-responsive">
+ <table class="table table-striped table-bordered table-condensed">
+ <% @global_stats.each do |name, value| %>
+ <tr>
+ <td><%= name.to_s.titleize %></td>
+ <td><b><%= value %></b></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </div>
+ </div>
+ <% end %>
+
<div class="col-xs-4">
<div id="jobs_status"></div>
</div>
<div class="col-xs-4">
<div id="jobs_stats"></div>
</div>
- <div class="col-xs-4">
- <%= bootstrap_form_tag(url: path, method: :post, layout: :inline) do |f| %>
- <%= f.select(:days_back, [['1 week', 7], ['2 weeks', 14], ['1 month', 30]], selected: params[:days_back]) %>
- <%= f.submit 'See Stats', class: "btn btn-primary" %>
- <% end %>
- </div>
</div>
<%= archiving_chart('jobs_status', @job_status) %>
<%= archiving_chart('jobs_stats', @job_stats) %>
diff --git a/lib/global_stats.rb b/lib/global_stats.rb
new file mode 100644
index 0000000..b20efcd
--- /dev/null
+++ b/lib/global_stats.rb
@@ -0,0 +1,31 @@
+class GlobalStats
+ include ActionView::Helpers::NumberHelper
+
+ def stats
+ {
+ Clients: Client.count,
+ Jobs: Job.count,
+ FileSets: FileSet.count,
+ Schedules: Schedule.count,
+ TotalBytes: number_to_human_size(Job.sum(:job_bytes)),
+ TotalFiles: number_to_human(Job.sum(:job_files),
+ units: { thousand: :K, million: :M, billion: :G },
+ precision: 5, significant: false),
+ Volumes: Media.count,
+ VolumesSize: number_to_human_size(Media.sum(:VolBytes)),
+ Pools: Pool.count,
+ DatabaseSize: number_to_human_size(db_size, precision: 2, significant: false)
+ }
+ end
+
+ private
+
+ def db_size
+ ActiveRecord::Base.connection.
+ execute("select sum(data_length + index_length) from information_schema.TABLES where TABLE_SCHEMA='bacula';").
+ first.first.to_f
+ rescue
+ 0
+ end
+end
+#Database Size
Event Timeline
Log In to Comment