riemann-redis-hybris 0.2.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c541732ce742356a0b4dd402633a3edb9aa0de4
4
+ data.tar.gz: f2a6c59e6edf439ac7df3f0e2c6011c2cc9e94ea
5
+ SHA512:
6
+ metadata.gz: dfb73548ca77b4f74d70d5e3a553d3cafbd08f50512523b0c67f3111e4df7aab1cfcf2a71ae64c090f1a86ba0d3ac3fdf41d01818e3413d19a099c86131abb3b
7
+ data.tar.gz: 0ca6cb55463b4cab0e125093385cfecfeb25652e9bbb12c8c397b2b1791bf5f2a1178a1ac9da708e473d7f13a45e78005bb8d3f23b32b481be78895d64990eab
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,41 @@
1
+ Riemann Redis
2
+ =============
3
+
4
+ Simple redis riemann client.
5
+
6
+ Submits the result of INFO [section] and SLOWLOG query into riemann.
7
+
8
+ Supports multiple sections by performing multiple INFO queries.
9
+
10
+ Local installation
11
+ ==========
12
+
13
+ ```
14
+ rake package
15
+ gem install --local pkg/riemann-redis-0.2.2.gem
16
+ ```
17
+
18
+ Get started
19
+ ==========
20
+
21
+ ``` bash
22
+ gem install riemann-redis
23
+ riemann-redis --help
24
+ riemann-redis-slowlog --help
25
+ riemann-redis-dynomite --help
26
+ ```
27
+
28
+ Multiple --redis-sections can by specified, for example if you want to monitor both Memory and Replication
29
+
30
+ ``` bash
31
+ riemann-redis --redis-section "Replication" --redis-section "Memory"
32
+ ```
33
+
34
+ Dynomite extension
35
+ ===========
36
+
37
+ Submits the length of matching collections in Redis into riemann.
38
+
39
+ ``` bash
40
+ riemann-redis-dynomite
41
+ ```
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gathers redis INFO statistics and submits them to Riemann.
4
+
5
+ require 'riemann/tools'
6
+
7
+ class Riemann::Tools::Redis
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
+ opt :redis_section, "Redis INFO section", :type => String, :multi => true, :default => 'default'
17
+
18
+ STRING_VALUES = %w{ redis_version redis_git_sha1 redis_mode os
19
+ multiplexing_api gcc_version run_id used_memory_human
20
+ used_memory_peak_human mem_allocator
21
+ rdb_last_bgsave_status aof_last_bgrewrite_status role }
22
+
23
+ def initialize
24
+ options = if opts[:redis_url] != ''
25
+ { :url => opts[:redis_url] }
26
+ elsif opts[:redis_socket] != ''
27
+ { :path => opts[:redis_socket] }
28
+ else
29
+ { :host => opts[:redis_host], :port => opts[:redis_port] }
30
+ end
31
+ @redis = ::Redis.new(options)
32
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
33
+ @section = opts[:redis_section]
34
+ end
35
+
36
+ def tick
37
+ begin
38
+ @section.each do |section|
39
+ @redis.info(section).each do |property, value|
40
+ data = {
41
+ :host => opts[:redis_host].dup,
42
+ :service => "redis #{property}",
43
+ :metric => value.to_s,
44
+ :state => value.to_s,
45
+ :tags => ['redis']
46
+ }
47
+
48
+ if STRING_VALUES.include?(property) || property.match(/^db\d+/)
49
+ if %w{ rdb_last_bgsave_status aof_last_bgrewrite_status }.include?(property)
50
+ data[:state] = value
51
+ else
52
+ data[:description] = value
53
+ end
54
+ end
55
+
56
+ if property == "run_id"
57
+ data[:metric] = 0
58
+ end
59
+ report(data)
60
+ end
61
+ end
62
+ rescue ::Redis::CommandError => e
63
+ if e.message == "ERR operation not permitted"
64
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ Riemann::Tools::Redis.run
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gathers redis zset, hashes lengths for given whitelist (by default yprofile.*) of collection and submits them to Riemann.
4
+
5
+ require 'riemann/tools'
6
+
7
+ class Riemann::Tools::RedisDynamoExtension
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
+ opt :redis_section, "Redis INFO section", :type => String, :multi => true, :default => 'default'
17
+ opt :redis_collection_whitelist_pattern, "Redis collection whitelist", :type => String, :default => 'yprofile.*'
18
+
19
+ STRING_VALUES = %w{ redis_version redis_git_sha1 redis_mode os
20
+ multiplexing_api gcc_version run_id used_memory_human
21
+ used_memory_peak_human mem_allocator
22
+ rdb_last_bgsave_status aof_last_bgrewrite_status role }
23
+
24
+ def initialize
25
+ options = if opts[:redis_url] != ''
26
+ { :url => opts[:redis_url] }
27
+ elsif opts[:redis_socket] != ''
28
+ { :path => opts[:redis_socket] }
29
+ else
30
+ { :host => opts[:redis_host], :port => opts[:redis_port] }
31
+ end
32
+ @redis = ::Redis.new(options)
33
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
34
+ @section = opts[:redis_section]
35
+ @collectionWhiteList = opts[:redis_collection_whitelist_pattern]
36
+ end
37
+
38
+ def tick
39
+ begin
40
+ p "tick #{@collectionWhiteList}"
41
+ @redis.keys(@collectionWhiteList).each do |property, value|
42
+ data = {
43
+ :host => opts[:redis_host].dup,
44
+ :service => "redis #{property}",
45
+ :tags => ['redis']
46
+ }
47
+ p "Bucket matching #{property}"
48
+ bucketType = @redis.type(property.to_s)
49
+ if 'zset' == bucketType
50
+ reportSetLength property, data
51
+ elsif 'hash' == bucketType then
52
+ reportHashLength property, data
53
+ else
54
+ p 'ERR Unsupported collection type #{property}'
55
+ end
56
+
57
+ if property == "run_id"
58
+ data[:metric] = 0
59
+ end
60
+ report(data)
61
+ end
62
+ end
63
+ rescue ::Redis::CommandError => e
64
+ if e.message == "ERR operation not permitted"
65
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
66
+ end
67
+ #end
68
+
69
+ end
70
+
71
+ def reportSetLength( setName, notification )
72
+ begin
73
+ p 'reportSetLength'
74
+ length = @redis.zlexcount(setName,'-', '+')
75
+ notification[:metric] = length.to_s
76
+ notification[:state] = length.to_s
77
+ notification[:description] = "Redis set #{setName} length"
78
+ p 'length '+length.to_s
79
+ rescue Exception => e
80
+ p e
81
+ end
82
+ end
83
+
84
+ def reportHashLength( hashName, notification )
85
+ begin
86
+ p 'reportHashLength'
87
+ length = @redis.hlen(hashName)
88
+ notification[:metric] = length.to_s
89
+ notification[:state] = length.to_s
90
+ notification[:description] = "Redis hash #{hashName} length"
91
+ p 'length '+length.to_s
92
+ rescue Exception => e
93
+ p e
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ Riemann::Tools::RedisDynamoExtension.run
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gathers Redis SLOWLOG statistics and submits them to Riemann.
4
+
5
+ require 'riemann/tools'
6
+
7
+ class Riemann::Tools::RedisSlowlog
8
+ include Riemann::Tools
9
+ require 'redis'
10
+
11
+ opt :redis_url, "Redis URL", :default => 'redis://127.0.0.1:6379/'
12
+ opt :redis_password, "Redis password", :default => ''
13
+ opt :slowlog_len, "Number of SLOWLOG entries to get", :default => 10
14
+ opt :slowlog_reset, "Reset SLOWLOG after querying it", :default => false
15
+
16
+ def initialize
17
+ @redis = ::Redis.new(url: opts[:redis_url])
18
+
19
+ @slowlog_len = opts[:slowlog_len]
20
+ @slowlog_reset = opts[:slowlog_reset]
21
+
22
+ @redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
23
+ end
24
+
25
+ def tick
26
+ @redis.slowlog("GET", @slowlog_len).each do |id, timestamp, us, cmd|
27
+ data = {
28
+ :host => @redis.client.host,
29
+ :service => "redis",
30
+ :time => timestamp,
31
+ :metric => us.to_f,
32
+ :state => 'warning',
33
+ :tags => ['redis', 'slowlog'],
34
+ :description => cmd.inspect
35
+ }
36
+ report(data)
37
+ end
38
+
39
+ @redis.slowlog("RESET") if @slowlog_reset
40
+ end
41
+
42
+ end
43
+
44
+ Riemann::Tools::RedisSlowlog.run
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-redis-hybris
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Mariusz Donigiewicz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-29 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.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.1
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: mariusz.donigiewicz@gmail.com
43
+ executables:
44
+ - riemann-redis
45
+ - riemann-redis-dynomite
46
+ - riemann-redis-slowlog
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - LICENSE
51
+ - README.md
52
+ - bin/riemann-redis
53
+ - bin/riemann-redis-dynomite
54
+ - bin/riemann-redis-slowlog
55
+ homepage: https://github.com/maryoush/riemann-redis
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.8.7
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: riemann-redis-hybris
74
+ rubygems_version: 2.5.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Redis client that submits events to Riemann.
78
+ test_files: []