rredis 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.autotest +23 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +18 -0
  6. data/Gemfile.lock +68 -0
  7. data/History.txt +6 -0
  8. data/Manifest.txt +40 -0
  9. data/README.md +143 -0
  10. data/Rakefile +34 -0
  11. data/benchmark/default.rb +62 -0
  12. data/benchmark/pipeline.rb +57 -0
  13. data/bin/rredis_server +7 -0
  14. data/config.ru +5 -0
  15. data/lib/lua/get.lua +74 -0
  16. data/lib/lua/store.lua +170 -0
  17. data/lib/rredis.rb +61 -0
  18. data/lib/rredis/server.rb +63 -0
  19. data/lib/rredis/web/assets/javascripts/application.js +3 -0
  20. data/lib/rredis/web/assets/javascripts/main.js +97 -0
  21. data/lib/rredis/web/assets/javascripts/vendor/bootstrap.js +1726 -0
  22. data/lib/rredis/web/assets/javascripts/vendor/bootstrap.min.js +6 -0
  23. data/lib/rredis/web/assets/javascripts/vendor/highcharts/highcharts.js +202 -0
  24. data/lib/rredis/web/assets/javascripts/vendor/highcharts/modules/canvas-tools.js +133 -0
  25. data/lib/rredis/web/assets/javascripts/vendor/highcharts/modules/exporting.js +23 -0
  26. data/lib/rredis/web/assets/javascripts/vendor/highcharts/themes/dark-blue.js +263 -0
  27. data/lib/rredis/web/assets/javascripts/vendor/highcharts/themes/dark-green.js +263 -0
  28. data/lib/rredis/web/assets/javascripts/vendor/highcharts/themes/gray.js +262 -0
  29. data/lib/rredis/web/assets/javascripts/vendor/highcharts/themes/grid.js +95 -0
  30. data/lib/rredis/web/assets/javascripts/vendor/highcharts/themes/skies.js +89 -0
  31. data/lib/rredis/web/assets/javascripts/vendor/jquery.js +4 -0
  32. data/lib/rredis/web/assets/stylesheets/application.css +10 -0
  33. data/lib/rredis/web/assets/stylesheets/vendor/bootstrap-responsive.css +686 -0
  34. data/lib/rredis/web/assets/stylesheets/vendor/bootstrap.css +3990 -0
  35. data/lib/rredis/web/images/glyphicons-halflings-white.png +0 -0
  36. data/lib/rredis/web/images/glyphicons-halflings.png +0 -0
  37. data/lib/rredis/web/views/index.slim +7 -0
  38. data/lib/rredis/web/views/layout.slim +26 -0
  39. data/spec/rredis/get_spec.rb +47 -0
  40. data/spec/rredis/store_spec.rb +159 -0
  41. data/spec/spec_helper.rb +21 -0
  42. metadata +124 -0
@@ -0,0 +1,7 @@
1
+ div id="charts"
2
+
3
+ javascript:
4
+ $(document).ready(function() {
5
+ rredis = new RReDis();
6
+ rredis.createGraphs("#{@metrics.first}");
7
+ });
@@ -0,0 +1,26 @@
1
+ doctype html
2
+ html
3
+ head
4
+ link href='#{{root_path}}assets/application.css' media='screen' rel='stylesheet' type='text/css'
5
+ script type="text/javascript" src="#{{root_path}}assets/application.js"
6
+ title RReDis
7
+ body
8
+ .navbar.navbar-fixed-top
9
+ .navbar-inner
10
+ .container
11
+ a.brand href='#{{root_path}}'
12
+ | RReDis
13
+ ul.nav
14
+ li
15
+ select id="metrics"
16
+ - @metrics.each do |metric|
17
+ option name="#{metric}"
18
+ == metric
19
+ ul.nav.pull-right
20
+ li
21
+ li
22
+
23
+ .container
24
+ == yield
25
+
26
+
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe RReDis do
4
+ describe "getting data" do
5
+ let(:rrd) { RReDis.new }
6
+ let(:r) { Redis.new }
7
+ before(:all) do
8
+ r.keys('rrd_*').each do |key|
9
+ r.del key if key != 'rrd_default_config'
10
+ end
11
+ rrd.config("test", {:steps => 10, :rows => 3, :aggregations => ['average', 'min'], :rra => [{:steps => 30, :rows => 3, :xff => 0.5},
12
+ {:steps => 60, :rows => 3, :xff => 0.5}]})
13
+ value = 1
14
+ (10..270).step(10).each_slice(3) do |a|
15
+ a.each do |ts|
16
+ rrd.store('test', ts, value)
17
+ end
18
+ value += 1
19
+ end
20
+ end
21
+
22
+ it "should return values in the native resolution" do
23
+ rrd.get("test", 250, 270).should == [[250, 260, 270], [9, 9, 9]]
24
+ end
25
+
26
+ it "should return values of the first rra" do
27
+ rrd.get("test", 210, 270).should == [[195, 225, 255], [7, 8, 9]]
28
+ end
29
+
30
+ it "should return values of the second rra" do
31
+ rrd.get("test", 0, 270).should == [[30, 90, 150, 210], [1.5, 3.5, 5.5, 7.5]]
32
+ end
33
+
34
+ it "should return the min values if requested" do
35
+ rrd.get("test", 0, 270, 'min').should == [[30, 90, 150, 210], [1.0, 3.0, 5.0, 7.0]]
36
+ end
37
+
38
+ it "should return floats" do
39
+ rrd.config("floats", {:steps => 1, :rows => 3})
40
+ rrd.store('floats', 20, 1.1)
41
+ rrd.store('floats', 21, 2.2)
42
+ rrd.store('floats', 22, 3.312345678)
43
+ r.zcard('rrd_floats_1').should == 3
44
+ rrd.get("floats", 20, 22).should == [[20, 21, 22], [1.1, 2.2, 3.312345678]]
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+
3
+ describe RReDis do
4
+ describe "storing data" do
5
+ let(:rrd) { RReDis.new }
6
+ let(:r) { Redis.new }
7
+ before(:all) do
8
+ r.keys('rrd_*').each do |key|
9
+ r.del key if key != 'rrd_default_config'
10
+ end
11
+ end
12
+ it "should set the default config correctly" do
13
+ JSON.parse(r.get('rrd_default_config'), :symbolize_names => true).should == rrd.default_config
14
+ end
15
+
16
+ it "should round the timestamp correctly" do
17
+ rrd.config("timestamp", {:steps => 10, :rows => 3})
18
+ rrd.store('timestamp', 100, 1)
19
+ rrd.store('timestamp', 104.4, 2)
20
+ rrd.store('timestamp', 106.6, 3)
21
+ r.zrange('rrd_timestamp_10', 0, -1).should == ["100_2", "110_3"]
22
+ r.zcard('rrd_timestamp_10').should == 2
23
+ end
24
+
25
+ it "should correctly store three points" do
26
+ rrd.config("test2", {:steps => 1, :rows => 3})
27
+ rrd.store('test2', Time.now, 1)
28
+ rrd.store('test2', Time.now+1, 2)
29
+ rrd.store('test2', Time.now+2, 3)
30
+ r.zcard('rrd_test2_1').should == 3
31
+ end
32
+
33
+ it "should not store a point which timestamp is too far in the past" do
34
+ rrd.config("past", {:steps => 1, :rows => 3})
35
+ rrd.store('past', 10, 1)
36
+ rrd.store('past', 11, 2)
37
+ rrd.store('past', 8, 3)
38
+ r.zcard('rrd_past_1').should == 2
39
+ end
40
+
41
+ it "should store no more then three points" do
42
+ rrd.config("test3", {:steps => 1, :rows => 3})
43
+ rrd.store('test3', 20, 1)
44
+ rrd.store('test3', 21, 2)
45
+ rrd.store('test3', 22, 3)
46
+ rrd.store('test3', 23, 4)
47
+ r.zcard('rrd_test3_1').should == 3
48
+ r.zrange('rrd_test3_1', 0, -1).should == ["21_2", "22_3", "23_4"]
49
+ end
50
+
51
+ it "should store floats" do
52
+ rrd.config("floats", {:steps => 1, :rows => 3})
53
+ rrd.store('floats', 20, 1.1)
54
+ rrd.store('floats', 21, 2.2)
55
+ rrd.store('floats', 22, 3.312345678)
56
+ rrd.store('floats', 23, 4.444455)
57
+ r.zcard('rrd_floats_1').should == 3
58
+ r.zrange('rrd_floats_1', 0, -1).should == ["21_2.2", "22_3.312345678", "23_4.444455"]
59
+ end
60
+
61
+ it "should generate the averages correctly" do
62
+ rrd.config("test4", {:steps => 1, :rows => 3, :aggregations => ['average'], :rra => [{:steps => 3, :rows => 10, :xff => 0.0}]})
63
+ rrd.store('test4', 1, 1)
64
+ r.zrange('rrd_test4_3_average', 0, 0).first.should == "3_1"
65
+ rrd.store('test4', 2, 2)
66
+ r.zrange('rrd_test4_3_average', 0, 0).first.should == "3_1.5"
67
+ rrd.store('test4', 3, 3)
68
+ r.zrange('rrd_test4_3_average', 0, 0).first.should == "3_2"
69
+ r.zcard('rrd_test4_1').should == 3
70
+ r.zcard('rrd_test4_3_average').should == 1
71
+ rrd.store('test4', 4, 1)
72
+ r.zrange('rrd_test4_3_average', 0, 0).first.should == "3_2"
73
+ r.zrange('rrd_test4_3_average', 1, 1).first.should == "6_1"
74
+ r.zcard('rrd_test4_3_average').should == 2
75
+ end
76
+
77
+ it "should work with more then one rra" do
78
+ rrd.config("test5", {:steps => 1, :rows => 3, :aggregations => ['average'],
79
+ :rra => [{:steps => 3, :rows => 10, :xff => 0.1},
80
+ {:steps => 6, :rows => 10, :xff => 0.1}]})
81
+ 1.upto(6) do |x|
82
+ rrd.store('test5', x, x)
83
+ end
84
+ r.zcard('rrd_test5_1').should == 3
85
+ r.zcard('rrd_test5_3_average').should == 2
86
+ r.zrange('rrd_test5_3_average', 0, 0).first.should == "3_2"
87
+ r.zrange('rrd_test5_3_average', 1, 1).first.should == "6_5"
88
+ r.zcard('rrd_test5_6_average').should == 1
89
+ r.zrange('rrd_test5_6_average', 0, 0).first.should == "6_3.5"
90
+ r.zcard('rrd_test5_3_average').should == 2
91
+ end
92
+
93
+ it "should pipeline multiple store commands" do
94
+ rrd.config("pipeline", {:steps => 1, :rows => 3})
95
+ rrd.pipelined do |rrd|
96
+ rrd.store('pipeline', Time.now, 1)
97
+ rrd.store('pipeline', Time.now+1, 2)
98
+ rrd.store('pipeline', Time.now+2, 3)
99
+ rrd.store('pipeline', Time.now+3, 4)
100
+ end
101
+ r.zcard('rrd_pipeline_1').should == 3
102
+ end
103
+
104
+ it "should find the minima correctly" do
105
+ rrd.config("min", {:steps => 1, :rows => 3, :aggregations => ['min'], :rra => [{:steps => 3, :rows => 10, :xff => 0.1}]})
106
+ rrd.store('min', 1, 5)
107
+ rrd.store('min', 2, 2)
108
+ rrd.store('min', 3, 7)
109
+ r.zcard('rrd_min_1').should == 3
110
+ r.zcard('rrd_min_3_min').should == 1
111
+ rrd.store('min', 4, 5)
112
+ r.zrange('rrd_min_3_min', 0, 0).first.should == "3_2"
113
+ r.zrange('rrd_min_3_min', 1, 1).first.should == "6_5"
114
+ r.zcard('rrd_min_3_min').should == 2
115
+ end
116
+
117
+ it "should find the maxima correctly" do
118
+ rrd.config("max", {:steps => 1, :rows => 3, :aggregations => ['max'], :rra => [{:steps => 3, :rows => 10, :xff => 0.1}]})
119
+ rrd.store('max', 1, 5)
120
+ rrd.store('max', 2, 2)
121
+ rrd.store('max', 3, 7)
122
+ r.zcard('rrd_max_1').should == 3
123
+ r.zcard('rrd_max_3_max').should == 1
124
+ rrd.store('max', 4, 5)
125
+ r.zrange('rrd_max_3_max', 0, 0).first.should == "3_7"
126
+ r.zrange('rrd_max_3_max', 1, 1).first.should == "6_5"
127
+ r.zcard('rrd_max_3_max').should == 2
128
+ end
129
+
130
+ it "should find the sum correctly" do
131
+ rrd.config("sum", {:steps => 1, :rows => 3, :aggregations => ['sum'], :rra => [{:steps => 3, :rows => 10, :xff => 0.1}]})
132
+ rrd.store('sum', 1, 5)
133
+ rrd.store('sum', 2, 2)
134
+ rrd.store('sum', 3, 7)
135
+ r.zcard('rrd_sum_1').should == 3
136
+ r.zcard('rrd_sum_3_sum').should == 1
137
+ rrd.store('sum', 4, 5)
138
+ r.zrange('rrd_sum_3_sum', 0, 0).first.should == "3_14"
139
+ r.zrange('rrd_sum_3_sum', 1, 1).first.should == "6_5"
140
+ r.zcard('rrd_sum_3_sum').should == 2
141
+ end
142
+
143
+ it "should handle multiple aggregation methods correctly" do
144
+ rrd.config("mult", {:steps => 1, :rows => 3, :aggregations => ['average', 'max', 'min'], :rra => [{:steps => 3, :rows => 10, :xff => 0.1},
145
+ {:steps => 3, :rows => 10, :xff => 0.1}]})
146
+ rrd.store('mult', 1, 1)
147
+ rrd.store('mult', 2, 1)
148
+ rrd.store('mult', 3, 2)
149
+ r.zcard("rrd_mult_1").should == 3
150
+ r.zcard("rrd_mult_3_average").should == 1
151
+ r.zrange('rrd_mult_3_average', 0, 0).first.should == "3_1.3333333333333"
152
+ r.zcard("rrd_mult_3_min").should == 1
153
+ r.zrange('rrd_mult_3_min', 0, 0).first.should == "3_1"
154
+
155
+
156
+
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require "bundler"
8
+ Bundler.require(:default, :development)
9
+
10
+ if ENV['COVERAGE']
11
+ require 'simplecov'
12
+ SimpleCov.start
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.treat_symbols_as_metadata_keys_with_true_values = true
17
+ config.run_all_when_everything_filtered = true
18
+ config.filter_run :focus
19
+ end
20
+
21
+ require 'rredis'
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rredis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dominik Sander
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redis
16
+ requirement: &9569340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *9569340
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &9567360 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.10'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *9567360
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ requirement: &9583700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *9583700
47
+ description: RReDis - a round robin database backed by redis
48
+ email:
49
+ - git@dsander.de
50
+ executables:
51
+ - rredis_server
52
+ extensions: []
53
+ extra_rdoc_files:
54
+ - History.txt
55
+ - Manifest.txt
56
+ files:
57
+ - .autotest
58
+ - .rspec
59
+ - CHANGELOG.md
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.md
65
+ - Rakefile
66
+ - benchmark/default.rb
67
+ - benchmark/pipeline.rb
68
+ - bin/rredis_server
69
+ - config.ru
70
+ - lib/lua/get.lua
71
+ - lib/lua/store.lua
72
+ - lib/rredis.rb
73
+ - lib/rredis/server.rb
74
+ - lib/rredis/web/assets/javascripts/application.js
75
+ - lib/rredis/web/assets/javascripts/main.js
76
+ - lib/rredis/web/assets/javascripts/vendor/bootstrap.js
77
+ - lib/rredis/web/assets/javascripts/vendor/bootstrap.min.js
78
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/highcharts.js
79
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/modules/canvas-tools.js
80
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/modules/exporting.js
81
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/themes/dark-blue.js
82
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/themes/dark-green.js
83
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/themes/gray.js
84
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/themes/grid.js
85
+ - lib/rredis/web/assets/javascripts/vendor/highcharts/themes/skies.js
86
+ - lib/rredis/web/assets/javascripts/vendor/jquery.js
87
+ - lib/rredis/web/assets/stylesheets/application.css
88
+ - lib/rredis/web/assets/stylesheets/vendor/bootstrap-responsive.css
89
+ - lib/rredis/web/assets/stylesheets/vendor/bootstrap.css
90
+ - lib/rredis/web/images/glyphicons-halflings-white.png
91
+ - lib/rredis/web/images/glyphicons-halflings.png
92
+ - lib/rredis/web/views/index.slim
93
+ - lib/rredis/web/views/layout.slim
94
+ - spec/rredis/get_spec.rb
95
+ - spec/rredis/store_spec.rb
96
+ - spec/spec_helper.rb
97
+ - .gemtest
98
+ homepage: https://github.com/dsander/RReDis
99
+ licenses: []
100
+ post_install_message:
101
+ rdoc_options:
102
+ - --main
103
+ - README.md
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project: rredis
120
+ rubygems_version: 1.8.11
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: RReDis - dead simple monitoring and graphing round robin database using redis
124
+ test_files: []