redis_monitor 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26945d3beb81a7f251aae5d4d976656b7a1cffaa
4
- data.tar.gz: 454ce3146a697ca9dd7792f5ecebb4420803ca26
3
+ metadata.gz: 35f60167efa6552a21e54a934d0fd3fc39c5593d
4
+ data.tar.gz: ebc40b4984cba2595124b25933909e23deb2b28d
5
5
  SHA512:
6
- metadata.gz: ebd6dc834fd6c67c9b04e8aaae0566f4f6d7e6f5df5a1b0ac0133ff4d91bb64f8c1082b80231b03576403768f63bd2c869825c14d6f97b1d4b570cea695a133c
7
- data.tar.gz: 1d39a1fcc48714c37c7e423bb9cd66212ab0be0f04a937b329581d4e9a052faa273cd93a3f3edfc020333abf412749853d7d6a0899bb2fb74441a469a262e158
6
+ metadata.gz: e5d036c628c417d0731147c34d0f8062b570ca166397eb1734bfa3596e06e985e594bd0d1c486a5f5788db047ddf5965218c6ff3b1de252ac5d032f4efcab535
7
+ data.tar.gz: efa9bf5529f187609333e1df2b0bee8cc093339ae8fd0e3c6787c467e3c0c91ba794be1b868188c7d602db7ae09d2c69be25ca51a8d6b55fc1a61113c1046eae
data/README.md CHANGED
@@ -16,6 +16,11 @@ Then browse http://localhost:http_port
16
16
  --editable or --not-editable can be use to indicate if the user should be able to edit the database content.
17
17
  --credentials user:password if only users with credentials can access the application.
18
18
 
19
+ If no database config is specified a sqlite3 database will be created inside the gem. To define database configuration you can use --database-adapter, --database-host, --database-port, --database-name
20
+
21
+ For example:
22
+
23
+ $ redis_monitor --database-adapter mysql2 --database-name redis_monitor --database-host localhost --database-port 3306
19
24
 
20
25
  For more information about the parameters:
21
26
 
@@ -27,6 +32,18 @@ You can define tasks in 'Task' tab and they will be running in background. There
27
32
  - Watch query, it will watch the query introduced in 'trigger' field and in the result of the query changes it will create a notification.
28
33
  Be careful with this one, don't watch queries too generic because it can affect to the performance of your database.
29
34
 
35
+ ## Screenshots
36
+
37
+ ![](https://dl.dropboxusercontent.com/u/434578/redis_monitor_images/1.png)
38
+
39
+ ![](https://dl.dropboxusercontent.com/u/434578/redis_monitor_images/2.png)
40
+
41
+ ![](https://dl.dropboxusercontent.com/u/434578/redis_monitor_images/3.png)
42
+
43
+ ![](https://dl.dropboxusercontent.com/u/434578/redis_monitor_images/4.png)
44
+
45
+ ![](https://dl.dropboxusercontent.com/u/434578/redis_monitor_images/5.png)
46
+
30
47
  ## Contributing
31
48
 
32
49
  1. Fork it
data/Rakefile CHANGED
@@ -4,6 +4,8 @@ require File.expand_path('../lib/engine/config/application', __FILE__)
4
4
 
5
5
  Engine::Application.load_tasks
6
6
 
7
+ Rake.application.instance_variable_get('@tasks').delete('spec')
8
+
7
9
  RSpec::Core::RakeTask.new(:spec) do |config|
8
10
  config.rspec_opts = '--default-path lib/engine/spec'
9
11
  end
@@ -11,6 +11,7 @@ module RedisMonitor
11
11
 
12
12
  def self.parse(argv)
13
13
  arguments = DEFAULTS.dup
14
+ arguments[:database] ||= {}
14
15
 
15
16
  parser = OptionParser.new do |op|
16
17
  op.on('--http-port port', 'specify http port (default is 6369)') do |val|
@@ -34,6 +35,22 @@ module RedisMonitor
34
35
  user, password = val.to_s.split(':')
35
36
  arguments[:credentials] = {user: user, password: password}
36
37
  end
38
+ op.on('--database-adapter database-adapter', 'database adapter (mysql2, sqlite3...)') do |val|
39
+ arguments[:database][:adapter] = val
40
+ arguments[:database_config] = true
41
+ end
42
+ op.on('--database-host database-host', 'database host') do |val|
43
+ arguments[:database][:host] = val
44
+ arguments[:database_config] = true
45
+ end
46
+ op.on('--database-port database-port', 'database port') do |val|
47
+ arguments[:database][:port] = val
48
+ arguments[:database_config] = true
49
+ end
50
+ op.on('--database-name database-name', 'database name') do |val|
51
+ arguments[:database][:database] = val
52
+ arguments[:database_config] = true
53
+ end
37
54
  end
38
55
  parser.parse!(argv)
39
56
 
@@ -1,8 +1,10 @@
1
1
  class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
2
  protect_from_forgery with: :exception
5
3
 
4
+ rescue_from Redis::CannotConnectError, :with => :redis_not_available
5
+
6
+ helper_method :backend
7
+
6
8
  if Authentication.authentication_required?
7
9
  http_basic_authenticate_with name: Authentication.credentials[:user], password: Authentication.credentials[:password]
8
10
  end
@@ -10,4 +12,8 @@ class ApplicationController < ActionController::Base
10
12
  def backend
11
13
  @backend ||= BackendConnection.build(current_database: session[:database])
12
14
  end
15
+
16
+ def redis_not_available
17
+ render 'layouts/redis_not_available'
18
+ end
13
19
  end
@@ -3,7 +3,7 @@ class NotificationsController < ApplicationController
3
3
  before_action :load_section
4
4
 
5
5
  def index
6
- @notifications = Notification.all
6
+ @notifications = Notification.paginate(:page => params[:page], :per_page => 20)
7
7
  end
8
8
 
9
9
  def destroy
@@ -1,8 +1,15 @@
1
1
  class PerformanceController < ApplicationController
2
+ before_action :load_section
3
+
2
4
  def index
3
5
  end
4
6
 
5
7
  def check
6
8
  @stats = PerformanceStats.new(backend).result
7
9
  end
10
+
11
+ private
12
+ def load_section
13
+ @section = 'performance'
14
+ end
8
15
  end
@@ -28,4 +28,8 @@ module ApplicationHelper
28
28
  def edit_class
29
29
  'btn btn-primary'
30
30
  end
31
+
32
+ def redis_configuration_string
33
+ "#{backend.host}:#{backend.port}"
34
+ end
31
35
  end
@@ -2,7 +2,7 @@ require 'will_paginate-bootstrap'
2
2
 
3
3
  module PaginationHelper
4
4
  def bootstrap_paginate(results)
5
- will_paginate results, renderer: BootstrapPagination::Rails
5
+ will_paginate results, renderer: BootstrapPagination::Rails, previous_label: '<<', next_label: '>>'
6
6
  end
7
7
  end
8
8
 
@@ -1,5 +1,3 @@
1
- require 'redis'
2
-
3
1
  class Backend
4
2
  attr_accessor :host, :port, :current_database
5
3
 
@@ -0,0 +1,3 @@
1
+ .message_centered
2
+ = "Can not connect to redis instance #{redis_configuration_string}"
3
+
@@ -12,3 +12,5 @@
12
12
 
13
13
  %tbody
14
14
  = render @notifications
15
+
16
+ = bootstrap_paginate @notifications
@@ -5,4 +5,8 @@ if defined?(REDIS_MONITOR_OPTS)
5
5
  end
6
6
  Authorization.setup(REDIS_MONITOR_OPTS[:permissions])
7
7
  Authentication.setup(REDIS_MONITOR_OPTS[:credentials])
8
+
9
+ if REDIS_MONITOR_OPTS[:database_config]
10
+ ActiveRecord::Base.establish_connection(REDIS_MONITOR_OPTS[:database])
11
+ end
8
12
  end
@@ -0,0 +1 @@
1
+ require 'redis'
@@ -1 +1,2 @@
1
- require 'will_paginate/array'
1
+ require 'will_paginate/array'
2
+ require 'will_paginate/active_record'
@@ -2,7 +2,7 @@ class CreateNotifications < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :notifications do |t|
4
4
  t.string :reporter, default: ''
5
- t.text :message, default: ''
5
+ t.text :message
6
6
 
7
7
  t.timestamps
8
8
  end
@@ -27,11 +27,11 @@ ActiveRecord::Schema.define(version: 20140118183403) do
27
27
  t.datetime "updated_at"
28
28
  end
29
29
 
30
- add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority"
30
+ add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
31
31
 
32
32
  create_table "notifications", force: true do |t|
33
33
  t.string "reporter", default: ""
34
- t.text "message", default: ""
34
+ t.text "message"
35
35
  t.datetime "created_at"
36
36
  t.datetime "updated_at"
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module RedisMonitor
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -24,13 +24,14 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  if defined?(JRUBY_VERSION)
26
26
  spec.add_runtime_dependency 'activerecord-jdbcsqlite3-adapter'
27
+ spec.add_runtime_dependency 'activerecord-jdbcmysql-adapter'
27
28
  else
28
29
  spec.add_runtime_dependency 'sqlite3'
30
+ spec.add_runtime_dependency 'mysql2'
29
31
  end
30
32
 
31
33
  spec.add_runtime_dependency 'jquery-rails'
32
34
  spec.add_runtime_dependency 'haml', '~> 4.0'
33
- spec.add_runtime_dependency 'twitter-bootstrap-rails'
34
35
  spec.add_runtime_dependency 'will_paginate', '~> 3.0.5'
35
36
  spec.add_runtime_dependency 'will_paginate-bootstrap'
36
37
  spec.add_runtime_dependency 'delayed_job_active_record'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Jimenez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-19 00:00:00.000000000 Z
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: jquery-rails
56
+ name: mysql2
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -67,33 +67,33 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: haml
70
+ name: jquery-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: '4.0'
75
+ version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
- version: '4.0'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: twitter-bootstrap-rails
84
+ name: haml
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '4.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '4.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: will_paginate
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -261,6 +261,7 @@ files:
261
261
  - lib/engine/app/views/content/search.haml
262
262
  - lib/engine/app/views/info/index.haml
263
263
  - lib/engine/app/views/layouts/application.haml
264
+ - lib/engine/app/views/layouts/redis_not_available.haml
264
265
  - lib/engine/app/views/notifications/_notification.haml
265
266
  - lib/engine/app/views/notifications/index.haml
266
267
  - lib/engine/app/views/performance/check.haml
@@ -289,6 +290,7 @@ files:
289
290
  - lib/engine/config/initializers/haml.rb
290
291
  - lib/engine/config/initializers/inflections.rb
291
292
  - lib/engine/config/initializers/mime_types.rb
293
+ - lib/engine/config/initializers/redis.rb
292
294
  - lib/engine/config/initializers/secret_token.rb
293
295
  - lib/engine/config/initializers/session_store.rb
294
296
  - lib/engine/config/initializers/will_paginate.rb
@@ -337,7 +339,6 @@ files:
337
339
  - lib/engine/spec/models/watch_key_task_spec.rb
338
340
  - lib/engine/spec/models/watch_query_task_spec.rb
339
341
  - lib/engine/spec/spec_helper.rb
340
- - lib/engine/tmp/.keep
341
342
  - lib/engine/vendor/assets/javascripts/.keep
342
343
  - lib/engine/vendor/assets/stylesheets/.keep
343
344
  - lib/redis_monitor.rb