redis-stat 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 620b88df3da7dcfd956b3145547b9fc45dd71063
4
- data.tar.gz: e63968613471cd7cbeb6bead4fc394393f625a26
3
+ metadata.gz: c56ec96d61c7fa7063f01dc425bcfbb297ede709
4
+ data.tar.gz: 60461ebf410c62beb58dde1c35fd83799561b6cd
5
5
  SHA512:
6
- metadata.gz: 16693f8340f90aff4f055be91472e54dd430db0e180106f24a46526e1a58ac73c66e4c7a8b8fdc17427138135147ee8bb8689e50e3c06805db89feb762759bed
7
- data.tar.gz: eb7769fd2ab7768ecd54ddab4c6242c51ed0a7ea9ff004e95c8de1e42566bf362a6fceae62f639bc99e2da40579fb75cb88fb51b1c9d64628f602684085746e5
6
+ metadata.gz: 2f939a8ab819e4ff7fc1bf8f60f0b253692fe15ba9e63b5c623da35a2e6648f6a20e75559893f7095d89351f09f694fdcb8a596df6cbf92224f42d1681d28b17
7
+ data.tar.gz: 1778b1b9693d3bbbe48b2c0964b84bb5e4c311adbee7e45470cd5acca1b541cb5fb6ef47204f691c5f2bcd198b0b99761c0e503b5ba3697203f0a5ffca3f5305
data/README.md CHANGED
@@ -23,7 +23,7 @@ it instead.
23
23
  ## Usage
24
24
 
25
25
  ```
26
- usage: redis-stat [HOST[:PORT] ...] [INTERVAL [COUNT]]
26
+ usage: redis-stat [HOST[:PORT][/PASS] ...] [INTERVAL [COUNT]]
27
27
 
28
28
  -a, --auth=PASSWORD Password
29
29
  -v, --verbose Show more info
@@ -84,14 +84,6 @@ If you're running Windows, you can only install redis-stat on
84
84
  [JRuby](http://jruby.org/). Notice that fancy terminal colors will not be
85
85
  printed as they are not supported in the default Windows command prompt.
86
86
 
87
- ## Author
88
- - [Junegunn Choi](https://github.com/junegunn)
89
-
90
- ## Contributors
91
- - [Chris Meisl](https://github.com/cmeisl)
92
- - [Hyunseok Hwang](https://github.com/frhwang)
93
- - [Sent Hil](https://github.com/sent-hil)
94
-
95
87
  ## Contributing
96
88
 
97
89
  1. Fork it
@@ -100,6 +92,15 @@ printed as they are not supported in the default Windows command prompt.
100
92
  4. Push to the branch (`git push origin my-new-feature`)
101
93
  5. Create new Pull Request
102
94
 
95
+ ### Test
96
+
97
+ You need two Redis servers running on localhost with port 6379 and 6380 with
98
+ no password.
99
+
100
+ ```sh
101
+ bundle install
102
+ bundle exec rake test
103
+
103
104
  ## About the name _redis-stat_
104
105
 
105
106
  Since this project was supposed to be a vmstat-like monitoring script for Redis,
@@ -28,10 +28,13 @@ class RedisStat
28
28
 
29
29
  @hosts = options[:hosts]
30
30
  @interval = options[:interval]
31
+ @auth = options[:auth]
31
32
  @redises = @hosts.inject({}) { |hash, e|
32
- host, port = e.split(':')
33
+ hostport, password = e.split('/')
34
+ host, port = hostport.split(':')
33
35
  hash[e] = Redis.new(Hash[ {:host => host,
34
36
  :port => port,
37
+ :password => password || @auth,
35
38
  :timeout => @interval}.select { |k, v| v } ])
36
39
  hash
37
40
  }
@@ -39,7 +42,6 @@ class RedisStat
39
42
  @colors = options[:colors] || COLORS
40
43
  @csv_file = options[:csv_file]
41
44
  @csv_output = options[:csv_output]
42
- @auth = options[:auth]
43
45
  @verbose = options[:verbose]
44
46
  @measures = MEASURES[ @verbose ? :verbose : :default ].map { |m| [*m].first }
45
47
  @tab_measures = MEASURES[:static].map { |m| [*m].first }
@@ -82,7 +84,6 @@ class RedisStat
82
84
  $stdout
83
85
  end
84
86
  update_term_size!
85
- authenticate!
86
87
 
87
88
  # Initial info collection
88
89
  info, x = collect
@@ -114,11 +115,6 @@ class RedisStat
114
115
  raise
115
116
  end
116
117
 
117
- if exceptions.any? { |k, v| need_auth? v }
118
- authenticate!
119
- next
120
- end
121
-
122
118
  info_output_all = process info, prev_info
123
119
  begin
124
120
  output_es Hash[info_output_all] if @elasticsearch && @count > 0
@@ -459,7 +455,7 @@ private
459
455
  })
460
456
  [humanize_number(val), val]
461
457
  when :evicted_keys_per_second, :expired_keys_per_second, :keyspace_hits_per_second,
462
- :keyspace_misses_per_second, :total_commands_processed_per_second
458
+ :keyspace_misses_per_second, :total_commands_processed_per_second, :rejected_connections_per_second
463
459
  val = get_diff.call(key.to_s.gsub(/_per_second$/, '').to_sym)
464
460
  [humanize_number(val), val]
465
461
  when :used_memory, :used_memory_rss, :aof_current_size, :aof_base_size
@@ -508,15 +504,4 @@ private
508
504
  end
509
505
  str
510
506
  end
511
-
512
- def need_auth? e
513
- @auth && e.is_a?(Redis::CommandError) &&
514
- e.to_s =~ /NOAUTH|operation not permitted/
515
- end
516
-
517
- def authenticate!
518
- @redises.values.each do |r|
519
- r.ping rescue (r.auth @auth)
520
- end if @auth
521
- end
522
507
  end
@@ -39,6 +39,7 @@ class RedisStat
39
39
  :used_cpu_sys,
40
40
  :connected_clients,
41
41
  :blocked_clients,
42
+ :rejected_connections_per_second,
42
43
  :used_memory,
43
44
  :used_memory_rss,
44
45
  :mem_fragmentation_ratio,
@@ -69,6 +70,7 @@ class RedisStat
69
70
  :used_cpu_sys => [:yellow],
70
71
  :connected_clients => [:cyan, :bold],
71
72
  :blocked_clients => [:cyan, :bold],
73
+ :rejected_connections_per_second => [:cyan],
72
74
  :used_memory => [:green],
73
75
  :used_memory_rss => [:green],
74
76
  :mem_fragmentation_ratio => [:green],
@@ -98,6 +100,7 @@ class RedisStat
98
100
  :used_cpu_sys => 'sy',
99
101
  :connected_clients => 'cl',
100
102
  :blocked_clients => 'bcl',
103
+ :rejected_connections_per_second => 'rej/s',
101
104
  :used_memory => 'mem',
102
105
  :used_memory_rss => 'rss',
103
106
  :mem_fragmentation_ratio => 'frag',
@@ -127,6 +130,8 @@ class RedisStat
127
130
  :used_cpu_sys => :f,
128
131
  :connected_clients => :i,
129
132
  :blocked_clients => :i,
133
+ :rejected_connections => :i,
134
+ :rejected_connections_per_second => :f,
130
135
  :used_memory => :i,
131
136
  :used_memory_rss => :i,
132
137
  :mem_fragmentation_ratio => :f,
@@ -1,3 +1,3 @@
1
1
  class RedisStat
2
- VERSION = '0.4.12'
2
+ VERSION = '0.4.13'
3
3
  end
@@ -27,9 +27,13 @@ Gem::Specification.new do |gem|
27
27
  gem.add_runtime_dependency "json", '~> 1.8.2'
28
28
  gem.add_runtime_dependency "lps", '~> 0.2.0'
29
29
  gem.add_runtime_dependency "elasticsearch", '~> 1.0.0'
30
+ gem.add_development_dependency "minitest"
31
+ gem.add_development_dependency "rake"
30
32
 
31
33
  if RUBY_PLATFORM == 'java'
32
- gem.add_runtime_dependency "puma", '~> 2.3.2'
34
+ gem.add_runtime_dependency "puma", "~> 2.3.2"
35
+ gem.add_development_dependency "jruby-jars", "1.7.19"
36
+ gem.add_development_dependency "warbler", "1.4.9"
33
37
  else
34
38
  gem.add_runtime_dependency "thin", '~> 1.5.0'
35
39
  gem.add_runtime_dependency "daemons", '~> 1.1.9'
@@ -2,14 +2,15 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  $VERBOSE = true
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
6
6
  require 'rubygems'
7
+ require 'bundler/setup'
7
8
  require 'redis-stat'
8
9
  require 'redis'
9
10
  require 'stringio'
10
11
  require 'minitest/autorun'
11
12
 
12
- class TestRedisStat < MiniTest::Unit::TestCase
13
+ class TestRedisStat < MiniTest::Test
13
14
  def test_humanize_number
14
15
  rs = RedisStat.new
15
16
  assert_equal '0', rs.send(:humanize_number, 0.00)
@@ -180,7 +181,7 @@ class TestRedisStat < MiniTest::Unit::TestCase
180
181
  csv = '/tmp/redis-stat.csv'
181
182
  cnt = 100
182
183
  rs = RedisStat.new :hosts => %w[localhost] * 5, :interval => 0.01, :count => cnt,
183
- :verbose => true, :csv_file => csv, :auth => 'pw'
184
+ :verbose => true, :csv_file => csv
184
185
  rs.start $stdout
185
186
 
186
187
  assert_equal cnt + 1, File.read(csv).lines.to_a.length
@@ -191,7 +192,7 @@ class TestRedisStat < MiniTest::Unit::TestCase
191
192
  def test_mono
192
193
  [true, false].each do |mono|
193
194
  rs = RedisStat.new :hosts => %w[localhost] * 5, :interval => 0.02, :count => 20,
194
- :verbose => true, :auth => 'pw', :mono => mono
195
+ :verbose => true, :mono => mono
195
196
  output = StringIO.new
196
197
  rs.start output
197
198
  puts output.string
@@ -205,8 +206,7 @@ class TestRedisStat < MiniTest::Unit::TestCase
205
206
  r2 = Redis.new(:host => 'localhost', :port => 6380)
206
207
 
207
208
  if r1.info['redis_version'] =~ /^2\.4/ && r2.info['redis_version'] =~ /^2\.2/
208
- rs = RedisStat.new :hosts => %w[localhost:6380 localhost], :interval => 1, :count => 1,
209
- :auth => 'pw', :style => :ascii
209
+ rs = RedisStat.new :hosts => %w[localhost:6380 localhost], :interval => 1, :count => 1, :style => :ascii
210
210
  output = StringIO.new
211
211
  rs.start output
212
212
  vline = output.string.lines.select { |line| line =~ /gcc_version/ }.first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junegunn Choi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2016-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi256
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.0.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: minitest
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: thin
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
268
  version: '0'
241
269
  requirements: []
242
270
  rubyforge_project:
243
- rubygems_version: 2.4.6
271
+ rubygems_version: 2.4.5.1
244
272
  signing_key:
245
273
  specification_version: 4
246
274
  summary: A real-time Redis monitoring tool written in Ruby