uzebba 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +58 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/uzebba_manifest.js +2 -0
  6. data/app/assets/javascripts/uzebba/uzebba.js +17 -0
  7. data/app/assets/stylesheets/uzebba/uzebba.css +42 -0
  8. data/app/controllers/uzebba/application_controller.rb +6 -0
  9. data/app/controllers/uzebba/terminals_controller.rb +16 -0
  10. data/app/helpers/uzebba/application_helper.rb +4 -0
  11. data/app/helpers/uzebba/terminals_helper.rb +20 -0
  12. data/app/jobs/uzebba/application_job.rb +4 -0
  13. data/app/jobs/uzebba/terminal_job.rb +14 -0
  14. data/app/mailers/uzebba/application_mailer.rb +6 -0
  15. data/app/models/uzebba/application_record.rb +5 -0
  16. data/app/models/uzebba/terminal.rb +4 -0
  17. data/app/views/layouts/uzebba/application.html.erb +15 -0
  18. data/app/views/uzebba/terminals/_cpu_usage.html.erb +11 -0
  19. data/app/views/uzebba/terminals/_memory_usage.html.erb +14 -0
  20. data/app/views/uzebba/terminals/_system_info.html.erb +64 -0
  21. data/app/views/uzebba/terminals/_terminals.html.erb +10 -0
  22. data/app/views/uzebba/terminals/index.html.erb +4 -0
  23. data/app/views/uzebba/terminals/index.js.erb +1 -0
  24. data/config/routes.rb +3 -0
  25. data/db/migrate/20180811032931_create_uzebba_terminals.rb +10 -0
  26. data/db/migrate/20180813220252_create_crono_jobs.rb +16 -0
  27. data/lib/generators/uzebba/install_generator.rb +45 -0
  28. data/lib/generators/uzebba/templates/cronotab.rb +28 -0
  29. data/lib/generators/uzebba/templates/migrate/create_crono_jobs.rb +16 -0
  30. data/lib/generators/uzebba/templates/migrate/create_uzebba_terminals.rb +10 -0
  31. data/lib/tasks/uzebba_tasks.rake +9 -0
  32. data/lib/uzebba/engine.rb +43 -0
  33. data/lib/uzebba/version.rb +3 -0
  34. data/lib/uzebba.rb +5 -0
  35. metadata +181 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73be8174e477e06224fb9a997c34a66476dd6d57
4
+ data.tar.gz: af6d8dac4906e8ea1fa2ed75b68149a806eb382b
5
+ SHA512:
6
+ metadata.gz: 7cb19959ba4c88a01bf73fe325baa4471b939b903857034fac0894014c74e82a5ba16987d1d6ecbe468ba2a3163dc882982698ddcda33ff9e42b806d04332568
7
+ data.tar.gz: 928747148cbcf4ff1375357b576b6b3ba037d1402d4b13d67ba67fbe9bdcc504adf90196261526e881120916c73c682037563fae751dfa4f84ab15a5f34ea97c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 odion ohio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Uzebba
2
+ <strong>Ruby on Rails monitoring tool for monitoring system performance (cpu & memory usage)</strong>
3
+ <p><small>Not yet complete. . .</small></p>
4
+
5
+ ## Installation
6
+ <strong>1. Add this line to your application's Gemfile:</strong>
7
+
8
+ ```ruby
9
+ gem 'uzebba', git: 'git://github.com/ohiodn8/uzebba.git'
10
+ ```
11
+
12
+ And then execute:
13
+ ```bash
14
+ $ bundle
15
+ ```
16
+
17
+ Or install it yourself as:
18
+ <pre><code><strike>$ gem install uzebba </strike></code></pre>
19
+
20
+
21
+ <hr>
22
+ <strong>2. Run Generator:</strong>
23
+ <pre><code>$ rails generate uzebba:install </code></pre>
24
+
25
+ <strong>Run Migration:</strong>
26
+ ```bash
27
+ $ rails db:migrate
28
+ ```
29
+
30
+ ## Usage
31
+ In routes.rb
32
+ ```ruby
33
+ mount Uzebba::Engine => "/uzebba"
34
+ ```
35
+
36
+ <strong>Visit: http://localhost:3000/uzebba</strong>
37
+
38
+
39
+
40
+
41
+ ## About the Gem
42
+ <p>This gem is a monitoring tool that monitors cpu and memory usage. The gem is based off of a tutorial that I decided to package as a gem. The gem heavily depends on the <a href="https://github.com/plashchynski/crono">crono gem</a> to handle background process, and <a href="https://github.com/ankane/chartkick">chartkick gem</a> for the monitoring charts. You don't have to install chartkick or crono as the uzebba gem will handle the installation.</p>
43
+
44
+ <p><strong><u>For Windows</u>: </strong> when you start the rails server, the gem will open a new cmd minimized on the taskbar. When you stop the rails server the application will also close the minimized cmd. This is the gem's way of imitating a Linux background process to handle the crono process.</p>
45
+
46
+ <p><strong><u>For Linux</u>: </strong> when you start the rails server, the crono process will run in background. To stop the process via the terminal, you have to do <code>ps aux | grep crono</code> to view the crono pid, and <code>kill -s sigterm [pid]</code> to terminate the process.</p>
47
+
48
+ <p><strong>Do not use in production.</strong></p>
49
+
50
+
51
+
52
+
53
+ ## Contributing
54
+ Contribution directions go here.
55
+
56
+
57
+ ## License
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Uzebba'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/uzebba .js
2
+ //= link_directory ../stylesheets/uzebba .css
@@ -0,0 +1,17 @@
1
+ // UZEBBA MONITORING TOOL JS
2
+ //
3
+ //= require rails-ujs
4
+ //= require jquery3.min
5
+ //= require Chart.bundle
6
+ //= require chartkick
7
+
8
+ // Ajax Controller for all terminal ID
9
+ $(function() {
10
+ if ($('#all_terminals').length) {
11
+ setInterval(function(){
12
+ $.getScript(window.location.pathname, function(data, textStatus, jqxhr) {
13
+ console.log('Load was performed.');
14
+ });
15
+ },3000);
16
+ }
17
+ });
@@ -0,0 +1,42 @@
1
+ /*
2
+ * UZEBBA MONITORING TOOL CSS
3
+ *
4
+ *= require_tree .
5
+ *= require_self
6
+ */
7
+
8
+ #tableau {
9
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
10
+ border-collapse: collapse;
11
+ width: 100%;
12
+ }
13
+
14
+ #tableau td, #tableau th {
15
+ border: 1px solid #ddd;
16
+ padding: 8px;
17
+ }
18
+
19
+ #tableau tr:nth-child(even){background-color: #f2f2f2;}
20
+
21
+ #tableau tr:hover {background-color: #ddd;}
22
+
23
+ #tableau th {
24
+ padding-top: 12px;
25
+ padding-bottom: 12px;
26
+ text-align: left;
27
+ background-color: #4CAF50;
28
+ color: white;
29
+ }
30
+
31
+ .grid-container {
32
+ display: grid;
33
+ grid-template-columns: 50% 50%;
34
+ background-color: #4CAF50;
35
+ padding: 10px;
36
+ }
37
+ .grid-item {
38
+ background-color: rgba(255, 255, 255, 0.8);
39
+ border: 1px solid rgba(0, 0, 0, 0.8);
40
+ padding: 20px;
41
+ text-align: center;
42
+ }
@@ -0,0 +1,6 @@
1
+ module Uzebba
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ require_dependency "uzebba/application_controller"
2
+
3
+ module Uzebba
4
+ class TerminalsController < ApplicationController
5
+ def index
6
+ @terminals = Terminal.order(Arel.sql(" created_at DESC")).all.first(10)
7
+ if Gem.win_platform?
8
+ @terminal = Terminal.create :memory_usage => (`wmic OS get TotalVisibleMemorySize /Value`.scan(/\d/).join('').to_d - `wmic OS get FreePhysicalMemory /Value`.scan(/\d/).join('').to_d)/1000,
9
+ :cpu_usage => `wmic cpu get loadpercentage`.scan(/\d/).join('').to_i
10
+ else
11
+ @terminal = Terminal.create :memory_usage => (`cat /proc/meminfo | grep MemTotal`.scan(/\d/).join('').to_d - `cat /proc/meminfo | grep MemFree`.scan(/\d/).join('').to_d)/1000,
12
+ :cpu_usage => `(grep 'cpu ' /proc/stat;sleep 0.1;grep 'cpu ' /proc/stat)|awk -v RS="" '{print "CPU "($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)"%"}'`.scan(/\d/).join('').to_f
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ module Uzebba
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module Uzebba
2
+ module TerminalsHelper
3
+ def total_mem
4
+ if Gem.win_platform?
5
+ `wmic OS get TotalVisibleMemorySize /Value`.scan(/\d/).join('').to_d/1000
6
+ else
7
+ `cat /proc/meminfo | grep MemTotal`.scan(/\d/).join('').to_d/1000
8
+ end
9
+ end
10
+
11
+ def available_mem
12
+ if Gem.win_platform?
13
+ `wmic OS get FreePhysicalMemory /Value`.scan(/\d/).join('').to_d/1000
14
+ else
15
+ `cat /proc/meminfo | grep MemFree`.scan(/\d/).join('').to_d/1000
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module Uzebba
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module Uzebba
2
+ class TerminalJob < ApplicationJob
3
+ queue_as :default
4
+
5
+ def perform(*args)
6
+ @terminals = Terminal.order(Arel.sql(" created_at DESC")).all.first(10)
7
+ if Gem.win_platform?
8
+ @terminal = Terminal.create :memory_usage => `wmic OS get TotalVisibleMemorySize /Value`.scan(/\d/).join('').to_i - `wmic OS get FreePhysicalMemory /Value`.scan(/\d/).join('').to_i, :cpu_usage => `wmic cpu get loadpercentage`.scan(/\d/).join('').to_i
9
+ else
10
+ @terminal = Terminal.create :memory_usage => `cat /proc/meminfo | grep MemTotal`.scan(/\d/).join('').to_i - `cat /proc/meminfo | grep MemFree`.scan(/\d/).join('').to_i
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ module Uzebba
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Uzebba
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Uzebba
2
+ class Terminal < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Uzebba</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag "uzebba/uzebba", media: "all" %>
8
+ <%= javascript_include_tag "uzebba/uzebba" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,11 @@
1
+ <h3>CPU USAGE</h3>
2
+ <%= line_chart Uzebba::Terminal.group_by_minute(:created_at).maximum(:cpu_usage) %>
3
+ <h3>
4
+ <% if Gem.win_platform? %>
5
+ <small style="color: green;">
6
+ CPU USAGE(win) => <%= `wmic cpu get loadpercentage`.scan(/\d/).join('').to_i %> %
7
+ </small>
8
+ <% else %>
9
+ <%= `(grep 'cpu ' /proc/stat;sleep 0.1;grep 'cpu ' /proc/stat)|awk -v RS="" '{print "CPU "($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)"%"}'`.scan(/\d/).join('').to_d %>
10
+ <% end %>
11
+ </h3>
@@ -0,0 +1,14 @@
1
+ <h3>
2
+ MEMORY [ TotalPhysicalMemory: <%= total_mem %> MB ]
3
+ </h3>
4
+ <%= area_chart Uzebba::Terminal.group_by_minute(:created_at).maximum(:memory_usage), min: @terminal.memory_usage.to_d - 200, xtitle: "Time", ytitle: "in Megabytes" %>
5
+ <br>
6
+ <h3>
7
+ <small style="color: blue;">
8
+ Available: <%= available_mem %> MB
9
+ </small> |
10
+ <small style="color: red;">
11
+ Used: <strong><u><%= @terminal.memory_usage %></u> MB</strong>
12
+ </small>
13
+
14
+ </h3>
@@ -0,0 +1,64 @@
1
+ <div class="grid-container">
2
+ <div class="grid-item">
3
+ <table id="tableau">
4
+ <tbody>
5
+ <tr>
6
+ <th>Tool Name</th>
7
+ <td><strong>Uzebba Monitoring Tool</strong> </td>
8
+ </tr>
9
+ <tr>
10
+ <th>Computer Name</th>
11
+ <td><%= Socket.gethostname %></td>
12
+ </tr>
13
+ <tr>
14
+ <th>OS</th>
15
+ <td>
16
+ <% if OS.windows? == true %>
17
+ Windows OS
18
+ <% elsif OS.mac? == true %>
19
+ Mac OS
20
+ <% elsif OS.posix? == true %>
21
+ Linux
22
+ <% elsif OS.java? == true %>
23
+ (jruby)
24
+ <% else %>
25
+ Hmmm...
26
+ <% end %>
27
+ </td>
28
+ </tr>
29
+ <tr>
30
+ <th>Home Path</th>
31
+ <td>
32
+ <% if OS.windows? == true %>
33
+ <%= `echo %HomePath%` %>
34
+ <% else %>
35
+ <%= `echo $HOME` %>
36
+ <% end %>
37
+ </td>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+ </div>
42
+ <div class="grid-item">
43
+ <table id="tableau">
44
+ <tbody>
45
+ <tr>
46
+ <th>Ruby Version</th>
47
+ <td><%= `ruby --version` %></td>
48
+ </tr>
49
+ <tr>
50
+ <th>Rails Version</th>
51
+ <td><%= `rails -v` %></td>
52
+ </tr>
53
+ <tr>
54
+ <th>Browser Version</th>
55
+ <td><%= browser.name %> <%= browser.full_version %></td>
56
+ </tr>
57
+ <tr>
58
+ <th>App Path</th>
59
+ <td><%= `pwd` %></td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+ </div>
64
+ </div>
@@ -0,0 +1,10 @@
1
+ <br>
2
+
3
+ <div class="grid-container">
4
+ <div class="grid-item">
5
+ <%= render "uzebba/terminals/memory_usage" %>
6
+ </div>
7
+ <div class="grid-item">
8
+ <%= render "uzebba/terminals/cpu_usage" %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,4 @@
1
+ <%= render "uzebba/terminals/system_info" %>
2
+ <div id="all_terminals">
3
+ <%= render "uzebba/terminals/terminals" %>
4
+ </div>
@@ -0,0 +1 @@
1
+ $("#all_terminals").html(" <%= escape_javascript(render 'terminals') %>" );
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Uzebba::Engine.routes.draw do
2
+ root "terminals#index"
3
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUzebbaTerminals < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :uzebba_terminals do |t|
4
+ t.decimal :memory_usage
5
+ t.integer :cpu_usage
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ class CreateCronoJobs < ActiveRecord::Migration[5.1]
2
+ def self.up
3
+ create_table :crono_jobs do |t|
4
+ t.string :job_id, null: false
5
+ t.text :log, limit: 1073741823 # LONGTEXT for MySQL
6
+ t.datetime :last_performed_at
7
+ t.boolean :healthy
8
+ t.timestamps null: false
9
+ end
10
+ add_index :crono_jobs, [:job_id], unique: true
11
+ end
12
+
13
+ def self.down
14
+ drop_table :crono_jobs
15
+ end
16
+ end
@@ -0,0 +1,45 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/active_record'
4
+
5
+ module Uzebba
6
+ module Generators
7
+ # rails generate uzebba:install
8
+ class InstallGenerator < ::Rails::Generators::Base
9
+ include Rails::Generators::Migration
10
+
11
+ def self.next_migration_number(path)
12
+ ActiveRecord::Generators::Base.next_migration_number(path)
13
+ end
14
+
15
+ desc 'Installs crono and generates the necessary configuration files'
16
+ source_root File.expand_path('../templates', __FILE__)
17
+
18
+ def create_migrations1
19
+ migration_template 'migrate/create_uzebba_terminals.rb',
20
+ 'db/migrate/create_uzebba_terminals.rb',
21
+ migration_version: migration_version
22
+ end
23
+
24
+ def create_migrations2
25
+ migration_template 'migrate/create_crono_jobs.rb',
26
+ 'db/migrate/create_crono_jobs.rb',
27
+ migration_version: migration_version
28
+ end
29
+
30
+ def copy_config
31
+ template 'cronotab.rb', 'config/cronotab.rb'
32
+ end
33
+
34
+ def rails5?
35
+ Rails.version.start_with? '5'
36
+ end
37
+
38
+ def migration_version
39
+ if rails5?
40
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ # cronotab.rb — Crono configuration file
2
+ #
3
+ # Here you can specify periodic jobs and schedule.
4
+ # class TestJob
5
+ # def perform
6
+ # puts 'Test!'
7
+ # end
8
+ # end
9
+ #
10
+ # Crono.perform(TestJob).every 2.days, at: '15:30'
11
+ #
12
+ class TerminalsJob
13
+ def perform
14
+ if Gem.win_platform?
15
+ @terminal = Uzebba::Terminal.create :memory_usage => (`wmic OS get TotalVisibleMemorySize /Value`.scan(/\d/).join('').to_d - `wmic OS get FreePhysicalMemory /Value`.scan(/\d/).join('').to_d)/1000, :cpu_usage => `wmic cpu get loadpercentage`.scan(/\d/).join('').to_i
16
+ else
17
+ @terminal = Uzebba::Terminal.create :memory_usage => (`cat /proc/meminfo | grep MemTotal`.scan(/\d/).join('').to_d - `cat /proc/meminfo | grep MemFree`.scan(/\d/).join('').to_d)/1000
18
+ end
19
+ end
20
+ end
21
+
22
+ class TerminalsDeleteJob
23
+ def perform
24
+ @terminal = Uzebba::Terminal.order('created_at ASC').limit(500).destroy_all
25
+ end
26
+ end
27
+ Crono.perform(TerminalsJob).every 1.minute
28
+ Crono.perform(TerminalsDeleteJob).every 4.hours
@@ -0,0 +1,16 @@
1
+ class CreateCronoJobs < ActiveRecord::Migration[5.1]
2
+ def self.up
3
+ create_table :crono_jobs do |t|
4
+ t.string :job_id, null: false
5
+ t.text :log, limit: 1073741823 # LONGTEXT for MySQL
6
+ t.datetime :last_performed_at
7
+ t.boolean :healthy
8
+ t.timestamps null: false
9
+ end
10
+ add_index :crono_jobs, [:job_id], unique: true
11
+ end
12
+
13
+ def self.down
14
+ drop_table :crono_jobs
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUzebbaTerminals < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :uzebba_terminals do |t|
4
+ t.decimal :memory_usage
5
+ t.integer :cpu_usage
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ ## desc "Creating Memory and CPU Usage"
2
+
3
+ #task :uzebba => :environment do
4
+ # if Gem.win_platform?
5
+ # terminal = Uzebba::Terminal.create :memory_usage => `wmic OS get TotalVisibleMemorySize /Value`.scan(/\d/).join('').to_i - `wmic OS get FreePhysicalMemory /Value`.scan(/\d/).join('').to_i, :cpu_usage => `wmic cpu get loadpercentage`.scan(/\d/).join('').to_i
6
+ # else
7
+ # terminal = Uzebba::Terminal.create :memory_usage => `cat /proc/meminfo | grep MemTotal`.scan(/\d/).join('').to_i - `cat /proc/meminfo | grep MemFree`.scan(/\d/).join('').to_i
8
+ # end
9
+ ## end
@@ -0,0 +1,43 @@
1
+ require 'jquery-rails'
2
+ require 'os'
3
+ require 'chartkick'
4
+ require 'groupdate'
5
+ require 'daemons'
6
+ require 'browser'
7
+ require 'crono'
8
+
9
+ module Uzebba
10
+ class Engine < ::Rails::Engine
11
+ isolate_namespace Uzebba
12
+
13
+ initializer 'Uzebba precompile hook', group: :all do |app|
14
+ app.config.assets.precompile += %w(
15
+ uzebba/uzebba.js
16
+ uzebba/uzebba.css
17
+ )
18
+ end
19
+
20
+
21
+ if defined?(Rails::Server)
22
+ ## CRONO Start Up
23
+ config.after_initialize do
24
+ if OS.windows?
25
+ system "echo *** CRONO STARTING IN NEW CMD. . . ***"
26
+ system 'start "uzebba19crono" /MIN bundle exec crono RAILS_ENV=development'
27
+ else
28
+ system "bundle exec crono start RAILS_ENV=development"
29
+ end
30
+ end
31
+ ## CRONO Terminate
32
+ if OS.windows?
33
+ def do_at_exit(str1)
34
+ at_exit { print str1 }
35
+ end
36
+ at_exit { system 'taskkill /FI "WindowTitle eq uzebba19crono*" /T /F' }
37
+ do_at_exit("***CRONO TERMINATED: ")
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Uzebba
2
+ VERSION = '0.1.0'
3
+ end
data/lib/uzebba.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "uzebba/engine"
2
+
3
+ module Uzebba
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uzebba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - odion ohio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jquery-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: os
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: chartkick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: groupdate
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: daemons
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: browser
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: crono
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.1'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.1.2
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '1.1'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.1.2
117
+ description: rails 5 application monitoring tool
118
+ email:
119
+ - ohiodn8@gmail.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - MIT-LICENSE
125
+ - README.md
126
+ - Rakefile
127
+ - app/assets/config/uzebba_manifest.js
128
+ - app/assets/javascripts/uzebba/uzebba.js
129
+ - app/assets/stylesheets/uzebba/uzebba.css
130
+ - app/controllers/uzebba/application_controller.rb
131
+ - app/controllers/uzebba/terminals_controller.rb
132
+ - app/helpers/uzebba/application_helper.rb
133
+ - app/helpers/uzebba/terminals_helper.rb
134
+ - app/jobs/uzebba/application_job.rb
135
+ - app/jobs/uzebba/terminal_job.rb
136
+ - app/mailers/uzebba/application_mailer.rb
137
+ - app/models/uzebba/application_record.rb
138
+ - app/models/uzebba/terminal.rb
139
+ - app/views/layouts/uzebba/application.html.erb
140
+ - app/views/uzebba/terminals/_cpu_usage.html.erb
141
+ - app/views/uzebba/terminals/_memory_usage.html.erb
142
+ - app/views/uzebba/terminals/_system_info.html.erb
143
+ - app/views/uzebba/terminals/_terminals.html.erb
144
+ - app/views/uzebba/terminals/index.html.erb
145
+ - app/views/uzebba/terminals/index.js.erb
146
+ - config/routes.rb
147
+ - db/migrate/20180811032931_create_uzebba_terminals.rb
148
+ - db/migrate/20180813220252_create_crono_jobs.rb
149
+ - lib/generators/uzebba/install_generator.rb
150
+ - lib/generators/uzebba/templates/cronotab.rb
151
+ - lib/generators/uzebba/templates/migrate/create_crono_jobs.rb
152
+ - lib/generators/uzebba/templates/migrate/create_uzebba_terminals.rb
153
+ - lib/tasks/uzebba_tasks.rake
154
+ - lib/uzebba.rb
155
+ - lib/uzebba/engine.rb
156
+ - lib/uzebba/version.rb
157
+ homepage: http://github.com/ohiodn8/uzebba
158
+ licenses:
159
+ - MIT
160
+ metadata: {}
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 2.5.2
178
+ signing_key:
179
+ specification_version: 4
180
+ summary: Simple rails 5 monitoring tool
181
+ test_files: []