riemann-redis-info 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 (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +14 -0
  4. data/bin/riemann-redis-info +69 -0
  5. metadata +74 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a94d55a970c385b25eb6a0a476627ec0cb40a68
4
+ data.tar.gz: b21245a9bdad45e113823bb5fdb75fe69f72de23
5
+ SHA512:
6
+ metadata.gz: 99848c0260d76609d7b4bf470c54f53fc88d92fe5a234dc1348d1490802fd0f98df67b95a72c66efcf32e40cedf9cf940ac00e1cce5a1bdb9da0f242bab97163
7
+ data.tar.gz: cfcddad5563849760b94c3cc58064a15820a1174abe766a40609f02139bed6523d4ee487e8405cc122a0f85ca9bc52e6940a4eeda3927a7bf511968bef8f4c80
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Kyle Kingsbury
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ Riemann Redis INFO
2
+ ===================
3
+
4
+ Simple Redis INFO riemann client.
5
+
6
+ Submits the result of INFO query into riemann.
7
+
8
+ Get started
9
+ ==========
10
+
11
+ ``` bash
12
+ gem install riemann-redis-info
13
+ riemann-redis-info --help
14
+ ```
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gathers redis INFO statistics and submits them to Riemann.
4
+
5
+ require File.expand_path('../../lib/riemann/tools', __FILE__)
6
+
7
+ class Riemann::Tools::RedisInfo
8
+ include Riemann::Tools
9
+ require 'redis'
10
+
11
+ opt :redis_host, "Redis hostname", :default => 'localhost'
12
+ opt :redis_port, "Redis port", :default => 6379
13
+ opt :redis_password, "Redis password", :default => ''
14
+ opt :redis_url, "Redis URL", :default => ''
15
+ opt :redis_socket, "Redis socket", :default => ''
16
+
17
+ STRING_VALUES = %w{ redis_version redis_git_sha1 redis_mode os
18
+ multiplexing_api gcc_version run_id used_memory_human
19
+ used_memory_peak_human mem_allocator
20
+ rdb_last_bgsave_status aof_last_bgrewrite_status role }
21
+
22
+ def initialize
23
+ options = if opts[:redis_url] != ''
24
+ { :url => opts[:redis_url] }
25
+ elsif opts[:redis_socket] != ''
26
+ { :path => opts[:redis_socket] }
27
+ else
28
+ { :host => opts[:redis_host], :port => opts[:redis_port] }
29
+ end
30
+ @redis = ::Redis.new(options)
31
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
32
+ end
33
+
34
+ def tick
35
+ begin
36
+ @redis.info().each do |property, value|
37
+ data = {
38
+ :host => opts[:redis_host].dup,
39
+ :service => "redis #{property}",
40
+ :metric => value.to_f,
41
+ :state => value.to_s,
42
+ :tags => ['redis']
43
+ }
44
+
45
+ if STRING_VALUES.include?(property) || property.match(/^db\d+/)
46
+ if %w{ rdb_last_bgsave_status aof_last_bgrewrite_status }.include?(property)
47
+ data[:state] = value
48
+ else
49
+ data[:description] = value
50
+ end
51
+ end
52
+
53
+ if property == "run_id"
54
+ data[:metric] = 0
55
+ end
56
+
57
+ report(data)
58
+ end
59
+ rescue ::Redis::CommandError => e
60
+ if e.message == "ERR operation not permitted"
61
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ Riemann::Tools::RedisInfo.run
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-redis-info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christian Blunden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: riemann-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.2
41
+ description:
42
+ email: christian.blunden@uswitch.com
43
+ executables:
44
+ - riemann-redis-info
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/riemann-redis-info
49
+ - LICENSE
50
+ - README.md
51
+ homepage: https://github.com/uswitch/riemann-redis-info
52
+ licenses: []
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.8.7
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project: riemann-redis-info
70
+ rubygems_version: 2.1.10
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Redis client that submit redis INFO events to Riemann.
74
+ test_files: []