sensu-plugins-redis 2.3.0 → 2.3.1
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 +5 -5
- data/CHANGELOG.md +6 -1
- data/README.md +4 -0
- data/bin/check-redis-info.rb +4 -48
- data/bin/check-redis-keys.rb +4 -57
- data/bin/check-redis-list-length.rb +4 -57
- data/bin/check-redis-memory-percentage.rb +5 -48
- data/bin/check-redis-memory.rb +4 -48
- data/bin/check-redis-ping.rb +4 -57
- data/bin/check-redis-slave-status.rb +5 -49
- data/bin/metrics-redis-graphite.rb +5 -59
- data/bin/metrics-redis-llen.rb +5 -48
- data/lib/redis_client_options.rb +93 -0
- data/lib/sensu-plugins-redis/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fcd104e903b24d8ccf311894925121ac6a79f3e2
|
4
|
+
data.tar.gz: ccd8600530603998ac4bb97e8566d34ca51bd29a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d0d86a5c2f2de6d5ed2a3aa523a2b9edbf4b7f6be84d450fdcad135dd91ceb4c105e649a4c5e58b10c1018612f2db6cbf08b629c35a1aabd1cf370c97cdddda
|
7
|
+
data.tar.gz: 002af62281c3d9f956fa44afaad55d0636460f0f6ab415867bb41bf521e52b676744111ea38d451db484e6576b36930b141ce0cd2f34446a219172bc9eaa1a23
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.3.1] - 2017-12-08
|
10
|
+
### Fixed
|
11
|
+
- ensure that `--socket` option is properly parsed and takes precedence over `--host`/`--port` (@mbyczkowski)
|
12
|
+
|
9
13
|
## [2.3.0] - 2017-11-12
|
10
14
|
### Added
|
11
15
|
- metrics-redis-llen.rb - Support passing multiple comma separated keys (@Evesy)
|
@@ -123,7 +127,8 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|
123
127
|
### Added
|
124
128
|
- initial release
|
125
129
|
|
126
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.3.
|
130
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.3.1...HEAD
|
131
|
+
[2.3.1]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.3.0...2.3.1
|
127
132
|
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.2.2...2.3.0
|
128
133
|
[2.2.2]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.2.1...2.2.2
|
129
134
|
[2.2.1]: https://github.com/sensu-plugins/sensu-plugins-redis/compare/2.2.0...2.2.1
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
## Files
|
12
12
|
* bin/check-redis-info.rb
|
13
|
+
* bin/check-redis-keys.rb
|
13
14
|
* bin/check-redis-list-length.rb
|
14
15
|
* bin/check-redis-memory.rb
|
15
16
|
* bin/check-redis-memory-percentage.rb
|
@@ -25,3 +26,6 @@
|
|
25
26
|
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
26
27
|
|
27
28
|
## Notes
|
29
|
+
|
30
|
+
[Developer Guidelines](http://sensu-plugins.io/docs/developer_guidelines.html)
|
31
|
+
[Testing](http://sensu-plugins.io/docs/testing.html)
|
data/bin/check-redis-info.rb
CHANGED
@@ -18,33 +18,10 @@
|
|
18
18
|
|
19
19
|
require 'sensu-plugin/check/cli'
|
20
20
|
require 'redis'
|
21
|
+
require_relative '../lib/redis_client_options'
|
21
22
|
|
22
23
|
class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
23
|
-
|
24
|
-
short: '-s SOCKET',
|
25
|
-
long: '--socket SOCKET',
|
26
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
27
|
-
required: false
|
28
|
-
|
29
|
-
option :host,
|
30
|
-
short: '-h HOST',
|
31
|
-
long: '--host HOST',
|
32
|
-
description: 'Redis Host to connect to',
|
33
|
-
required: false,
|
34
|
-
default: '127.0.0.1'
|
35
|
-
|
36
|
-
option :port,
|
37
|
-
short: '-p PORT',
|
38
|
-
long: '--port PORT',
|
39
|
-
description: 'Redis Port to connect to',
|
40
|
-
proc: proc(&:to_i),
|
41
|
-
required: false,
|
42
|
-
default: 6379
|
43
|
-
|
44
|
-
option :password,
|
45
|
-
short: '-P PASSWORD',
|
46
|
-
long: '--password PASSWORD',
|
47
|
-
description: 'Redis Password to connect with'
|
24
|
+
include RedisClientOptions
|
48
25
|
|
49
26
|
option :redis_info_key,
|
50
27
|
short: '-K VALUE',
|
@@ -60,29 +37,8 @@ class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
|
60
37
|
required: false,
|
61
38
|
default: 'master'
|
62
39
|
|
63
|
-
option :conn_failure_status,
|
64
|
-
long: '--conn-failure-status EXIT_STATUS',
|
65
|
-
description: 'Returns the following exit status for Redis connection failures',
|
66
|
-
default: 'unknown',
|
67
|
-
in: %w(unknown warning critical)
|
68
|
-
|
69
|
-
option :timeout,
|
70
|
-
short: '-t TIMEOUT',
|
71
|
-
long: '--timeout TIMEOUT',
|
72
|
-
description: 'Redis connection timeout',
|
73
|
-
proc: proc(&:to_i),
|
74
|
-
required: false,
|
75
|
-
default: 5
|
76
|
-
|
77
40
|
def run
|
78
|
-
|
79
|
-
{ path: socket }
|
80
|
-
else
|
81
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
82
|
-
end
|
83
|
-
|
84
|
-
options[:password] = config[:password] if config[:password]
|
85
|
-
redis = Redis.new(options)
|
41
|
+
redis = Redis.new(default_redis_options)
|
86
42
|
|
87
43
|
if redis.info.fetch(config[:redis_info_key].to_s) == config[:redis_info_value].to_s
|
88
44
|
ok "Redis #{config[:redis_info_key]} is #{config[:redis_info_value]}"
|
@@ -90,6 +46,6 @@ class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
|
90
46
|
critical "Redis #{config[:redis_info_key]} is #{redis.info.fetch(config[:redis_info_key].to_s)}!"
|
91
47
|
end
|
92
48
|
rescue
|
93
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
49
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
94
50
|
end
|
95
51
|
end
|
data/bin/check-redis-keys.rb
CHANGED
@@ -12,41 +12,10 @@
|
|
12
12
|
|
13
13
|
require 'sensu-plugin/check/cli'
|
14
14
|
require 'redis'
|
15
|
+
require_relative '../lib/redis_client_options'
|
15
16
|
|
16
17
|
class RedisKeysCheck < Sensu::Plugin::Check::CLI
|
17
|
-
|
18
|
-
short: '-s SOCKET',
|
19
|
-
long: '--socket SOCKET',
|
20
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
21
|
-
required: false
|
22
|
-
|
23
|
-
option :host,
|
24
|
-
short: '-h HOST',
|
25
|
-
long: '--host HOST',
|
26
|
-
description: 'Redis Host to connect to',
|
27
|
-
required: false,
|
28
|
-
default: '127.0.0.1'
|
29
|
-
|
30
|
-
option :port,
|
31
|
-
short: '-p PORT',
|
32
|
-
long: '--port PORT',
|
33
|
-
description: 'Redis Port to connect to',
|
34
|
-
proc: proc(&:to_i),
|
35
|
-
required: false,
|
36
|
-
default: 6379
|
37
|
-
|
38
|
-
option :database,
|
39
|
-
short: '-n DATABASE',
|
40
|
-
long: '--dbnumber DATABASE',
|
41
|
-
description: 'Redis database number to connect to',
|
42
|
-
proc: proc(&:to_i),
|
43
|
-
required: false,
|
44
|
-
default: 0
|
45
|
-
|
46
|
-
option :password,
|
47
|
-
short: '-P PASSWORD',
|
48
|
-
long: '--password PASSWORD',
|
49
|
-
description: 'Redis Password to connect with'
|
18
|
+
include RedisClientOptions
|
50
19
|
|
51
20
|
option :warn,
|
52
21
|
short: '-w COUNT',
|
@@ -68,30 +37,8 @@ class RedisKeysCheck < Sensu::Plugin::Check::CLI
|
|
68
37
|
required: false,
|
69
38
|
default: '*'
|
70
39
|
|
71
|
-
option :conn_failure_status,
|
72
|
-
long: '--conn-failure-status EXIT_STATUS',
|
73
|
-
description: 'Returns the following exit status for Redis connection failures',
|
74
|
-
default: 'unknown',
|
75
|
-
in: %w(unknown warning critical)
|
76
|
-
|
77
|
-
option :timeout,
|
78
|
-
short: '-t TIMEOUT',
|
79
|
-
long: '--timeout TIMEOUT',
|
80
|
-
description: 'Redis connection timeout',
|
81
|
-
proc: proc(&:to_i),
|
82
|
-
required: false,
|
83
|
-
default: 5
|
84
|
-
|
85
40
|
def run
|
86
|
-
|
87
|
-
{ path: socket }
|
88
|
-
else
|
89
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
90
|
-
end
|
91
|
-
|
92
|
-
options[:db] = config[:database]
|
93
|
-
options[:password] = config[:password] if config[:password]
|
94
|
-
redis = Redis.new(options)
|
41
|
+
redis = Redis.new(default_redis_options)
|
95
42
|
|
96
43
|
length = redis.keys(config[:pattern]).size
|
97
44
|
|
@@ -103,6 +50,6 @@ class RedisKeysCheck < Sensu::Plugin::Check::CLI
|
|
103
50
|
ok "Redis list #{config[:pattern]} length is above thresholds"
|
104
51
|
end
|
105
52
|
rescue
|
106
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
53
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
107
54
|
end
|
108
55
|
end
|
@@ -13,41 +13,10 @@
|
|
13
13
|
|
14
14
|
require 'sensu-plugin/check/cli'
|
15
15
|
require 'redis'
|
16
|
+
require_relative '../lib/redis_client_options'
|
16
17
|
|
17
18
|
class RedisListLengthCheck < Sensu::Plugin::Check::CLI
|
18
|
-
|
19
|
-
short: '-s SOCKET',
|
20
|
-
long: '--socket SOCKET',
|
21
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
22
|
-
required: false
|
23
|
-
|
24
|
-
option :host,
|
25
|
-
short: '-h HOST',
|
26
|
-
long: '--host HOST',
|
27
|
-
description: 'Redis Host to connect to',
|
28
|
-
required: false,
|
29
|
-
default: '127.0.0.1'
|
30
|
-
|
31
|
-
option :port,
|
32
|
-
short: '-p PORT',
|
33
|
-
long: '--port PORT',
|
34
|
-
description: 'Redis Port to connect to',
|
35
|
-
proc: proc(&:to_i),
|
36
|
-
required: false,
|
37
|
-
default: 6379
|
38
|
-
|
39
|
-
option :database,
|
40
|
-
short: '-n DATABASE',
|
41
|
-
long: '--dbnumber DATABASE',
|
42
|
-
description: 'Redis database number to connect to',
|
43
|
-
proc: proc(&:to_i),
|
44
|
-
required: false,
|
45
|
-
default: 0
|
46
|
-
|
47
|
-
option :password,
|
48
|
-
short: '-P PASSWORD',
|
49
|
-
long: '--password PASSWORD',
|
50
|
-
description: 'Redis Password to connect with'
|
19
|
+
include RedisClientOptions
|
51
20
|
|
52
21
|
option :warn,
|
53
22
|
short: '-w COUNT',
|
@@ -69,30 +38,8 @@ class RedisListLengthCheck < Sensu::Plugin::Check::CLI
|
|
69
38
|
description: 'Redis list KEY to check',
|
70
39
|
required: true
|
71
40
|
|
72
|
-
option :conn_failure_status,
|
73
|
-
long: '--conn-failure-status EXIT_STATUS',
|
74
|
-
description: 'Returns the following exit status for Redis connection failures',
|
75
|
-
default: 'unknown',
|
76
|
-
in: %w(unknown warning critical)
|
77
|
-
|
78
|
-
option :timeout,
|
79
|
-
short: '-t TIMEOUT',
|
80
|
-
long: '--timeout TIMEOUT',
|
81
|
-
description: 'Redis connection timeout',
|
82
|
-
proc: proc(&:to_i),
|
83
|
-
required: false,
|
84
|
-
default: 5
|
85
|
-
|
86
41
|
def run
|
87
|
-
|
88
|
-
{ path: config[:socket] }
|
89
|
-
else
|
90
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
91
|
-
end
|
92
|
-
|
93
|
-
options[:db] = config[:database]
|
94
|
-
options[:password] = config[:password] if config[:password]
|
95
|
-
redis = Redis.new(options)
|
42
|
+
redis = Redis.new(default_redis_options)
|
96
43
|
|
97
44
|
length = case redis.type(config[:key])
|
98
45
|
when 'hash'
|
@@ -111,6 +58,6 @@ class RedisListLengthCheck < Sensu::Plugin::Check::CLI
|
|
111
58
|
ok "Redis list #{config[:key]} length (#{length}) is below thresholds"
|
112
59
|
end
|
113
60
|
rescue
|
114
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
61
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
115
62
|
end
|
116
63
|
end
|
@@ -29,32 +29,10 @@
|
|
29
29
|
|
30
30
|
require 'sensu-plugin/check/cli'
|
31
31
|
require 'redis'
|
32
|
-
|
33
|
-
option :socket,
|
34
|
-
short: '-s SOCKET',
|
35
|
-
long: '--socket SOCKET',
|
36
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
37
|
-
required: false
|
38
|
-
|
39
|
-
option :host,
|
40
|
-
short: '-h HOST',
|
41
|
-
long: '--host HOST',
|
42
|
-
description: 'Redis Host to connect to',
|
43
|
-
required: false,
|
44
|
-
default: '127.0.0.1'
|
32
|
+
require_relative '../lib/redis_client_options'
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
long: '--port PORT',
|
49
|
-
description: 'Redis Port to connect to',
|
50
|
-
proc: proc(&:to_i),
|
51
|
-
required: false,
|
52
|
-
default: 6379
|
53
|
-
|
54
|
-
option :password,
|
55
|
-
short: '-P PASSWORD',
|
56
|
-
long: '--password PASSWORD',
|
57
|
-
description: 'Redis Password to connect with'
|
34
|
+
class RedisChecks < Sensu::Plugin::Check::CLI
|
35
|
+
include RedisClientOptions
|
58
36
|
|
59
37
|
option :warn_mem,
|
60
38
|
short: '-w percentage',
|
@@ -70,33 +48,12 @@ class RedisChecks < Sensu::Plugin::Check::CLI
|
|
70
48
|
proc: proc(&:to_i),
|
71
49
|
required: true
|
72
50
|
|
73
|
-
option :conn_failure_status,
|
74
|
-
long: '--conn-failure-status EXIT_STATUS',
|
75
|
-
description: 'Returns the following exit status for Redis connection failures',
|
76
|
-
default: 'unknown',
|
77
|
-
in: %w(unknown warning critical)
|
78
|
-
|
79
|
-
option :timeout,
|
80
|
-
short: '-t TIMEOUT',
|
81
|
-
long: '--timeout TIMEOUT',
|
82
|
-
description: 'Redis connection timeout',
|
83
|
-
proc: proc(&:to_i),
|
84
|
-
required: false,
|
85
|
-
default: 5
|
86
|
-
|
87
51
|
def system_memory
|
88
52
|
`awk '/MemTotal/{print$2}' /proc/meminfo`.to_f * 1024
|
89
53
|
end
|
90
54
|
|
91
55
|
def run
|
92
|
-
|
93
|
-
{ path: socket }
|
94
|
-
else
|
95
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
96
|
-
end
|
97
|
-
|
98
|
-
options[:password] = config[:password] if config[:password]
|
99
|
-
redis = Redis.new(options)
|
56
|
+
redis = Redis.new(default_redis_options)
|
100
57
|
|
101
58
|
redis_info = redis.info
|
102
59
|
max_memory = redis_info.fetch('maxmemory', 0).to_i
|
@@ -117,6 +74,6 @@ class RedisChecks < Sensu::Plugin::Check::CLI
|
|
117
74
|
ok "Redis memory usage: #{used_memory}% is below defined limits"
|
118
75
|
end
|
119
76
|
rescue
|
120
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
77
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
121
78
|
end
|
122
79
|
end
|
data/bin/check-redis-memory.rb
CHANGED
@@ -10,33 +10,10 @@
|
|
10
10
|
|
11
11
|
require 'sensu-plugin/check/cli'
|
12
12
|
require 'redis'
|
13
|
+
require_relative '../lib/redis_client_options'
|
13
14
|
|
14
15
|
class RedisChecks < Sensu::Plugin::Check::CLI
|
15
|
-
|
16
|
-
short: '-s SOCKET',
|
17
|
-
long: '--socket SOCKET',
|
18
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
19
|
-
required: false
|
20
|
-
|
21
|
-
option :host,
|
22
|
-
short: '-h HOST',
|
23
|
-
long: '--host HOST',
|
24
|
-
description: 'Redis Host to connect to',
|
25
|
-
required: false,
|
26
|
-
default: '127.0.0.1'
|
27
|
-
|
28
|
-
option :port,
|
29
|
-
short: '-p PORT',
|
30
|
-
long: '--port PORT',
|
31
|
-
description: 'Redis Port to connect to',
|
32
|
-
proc: proc(&:to_i),
|
33
|
-
required: false,
|
34
|
-
default: 6379
|
35
|
-
|
36
|
-
option :password,
|
37
|
-
short: '-P PASSWORD',
|
38
|
-
long: '--password PASSWORD',
|
39
|
-
description: 'Redis Password to connect with'
|
16
|
+
include RedisClientOptions
|
40
17
|
|
41
18
|
option :warn_mem,
|
42
19
|
short: '-w KB',
|
@@ -52,29 +29,8 @@ class RedisChecks < Sensu::Plugin::Check::CLI
|
|
52
29
|
proc: proc(&:to_i),
|
53
30
|
required: true
|
54
31
|
|
55
|
-
option :conn_failure_status,
|
56
|
-
long: '--conn-failure-status EXIT_STATUS',
|
57
|
-
description: 'Returns the following exit status for Redis connection failures',
|
58
|
-
default: 'unknown',
|
59
|
-
in: %w(unknown warning critical)
|
60
|
-
|
61
|
-
option :timeout,
|
62
|
-
short: '-t TIMEOUT',
|
63
|
-
long: '--timeout TIMEOUT',
|
64
|
-
description: 'Redis connection timeout',
|
65
|
-
proc: proc(&:to_i),
|
66
|
-
required: false,
|
67
|
-
default: 5
|
68
|
-
|
69
32
|
def run
|
70
|
-
|
71
|
-
{ path: socket }
|
72
|
-
else
|
73
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
74
|
-
end
|
75
|
-
|
76
|
-
options[:password] = config[:password] if config[:password]
|
77
|
-
redis = Redis.new(options)
|
33
|
+
redis = Redis.new(default_redis_options)
|
78
34
|
|
79
35
|
used_memory = redis.info.fetch('used_memory').to_i.div(1024)
|
80
36
|
warn_memory = config[:warn_mem]
|
@@ -87,6 +43,6 @@ class RedisChecks < Sensu::Plugin::Check::CLI
|
|
87
43
|
ok "Redis memory usage: #{used_memory}KB is below defined limits"
|
88
44
|
end
|
89
45
|
rescue
|
90
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
46
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
91
47
|
end
|
92
48
|
end
|
data/bin/check-redis-ping.rb
CHANGED
@@ -29,71 +29,18 @@
|
|
29
29
|
|
30
30
|
require 'sensu-plugin/check/cli'
|
31
31
|
require 'redis'
|
32
|
+
require_relative '../lib/redis_client_options'
|
32
33
|
|
33
34
|
class RedisPing < Sensu::Plugin::Check::CLI
|
34
|
-
|
35
|
-
short: '-s SOCKET',
|
36
|
-
long: '--socket SOCKET',
|
37
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
38
|
-
required: false
|
39
|
-
|
40
|
-
option :host,
|
41
|
-
short: '-h HOST',
|
42
|
-
long: '--host HOST',
|
43
|
-
description: 'Redis Host to connect to',
|
44
|
-
required: false,
|
45
|
-
default: '127.0.0.1'
|
46
|
-
|
47
|
-
option :port,
|
48
|
-
short: '-p PORT',
|
49
|
-
long: '--port PORT',
|
50
|
-
description: 'Redis Port to connect to',
|
51
|
-
proc: proc(&:to_i),
|
52
|
-
required: false,
|
53
|
-
default: 6379
|
54
|
-
|
55
|
-
option :password,
|
56
|
-
short: '-P PASSWORD',
|
57
|
-
long: '--password PASSWORD',
|
58
|
-
description: 'Redis Password to connect with'
|
59
|
-
|
60
|
-
option :conn_failure_status,
|
61
|
-
long: '--conn-failure-status EXIT_STATUS',
|
62
|
-
description: 'Returns the following exit status for Redis connection failures',
|
63
|
-
default: 'critical',
|
64
|
-
in: %w(unknown warning critical)
|
65
|
-
|
66
|
-
option :timeout,
|
67
|
-
short: '-t TIMEOUT',
|
68
|
-
long: '--timeout TIMEOUT',
|
69
|
-
description: 'Redis connection timeout',
|
70
|
-
proc: proc(&:to_i),
|
71
|
-
required: false,
|
72
|
-
default: 5
|
73
|
-
|
74
|
-
def redis_options
|
75
|
-
if config[:socket]
|
76
|
-
{
|
77
|
-
path: config[:socket],
|
78
|
-
password: config[:password]
|
79
|
-
}
|
80
|
-
else
|
81
|
-
{
|
82
|
-
host: config[:host],
|
83
|
-
port: config[:port],
|
84
|
-
password: config[:password],
|
85
|
-
timeout: config[:timeout]
|
86
|
-
}
|
87
|
-
end
|
88
|
-
end
|
35
|
+
include RedisClientOptions
|
89
36
|
|
90
37
|
def run
|
91
|
-
if Redis.new(
|
38
|
+
if Redis.new(default_redis_options).ping == 'PONG'
|
92
39
|
ok 'Redis is alive'
|
93
40
|
else
|
94
41
|
critical 'Redis did not respond to the ping command'
|
95
42
|
end
|
96
43
|
rescue
|
97
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
44
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
98
45
|
end
|
99
46
|
end
|
@@ -4,57 +4,13 @@
|
|
4
4
|
|
5
5
|
require 'sensu-plugin/check/cli'
|
6
6
|
require 'redis'
|
7
|
+
require_relative '../lib/redis_client_options'
|
7
8
|
|
8
9
|
class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
9
|
-
|
10
|
-
short: '-s SOCKET',
|
11
|
-
long: '--socket SOCKET',
|
12
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
13
|
-
required: false
|
14
|
-
|
15
|
-
option :host,
|
16
|
-
short: '-h HOST',
|
17
|
-
long: '--host HOST',
|
18
|
-
description: 'Redis Host to connect to',
|
19
|
-
required: false,
|
20
|
-
default: '127.0.0.1'
|
21
|
-
|
22
|
-
option :port,
|
23
|
-
short: '-p PORT',
|
24
|
-
long: '--port PORT',
|
25
|
-
description: 'Redis Port to connect to',
|
26
|
-
proc: proc(&:to_i),
|
27
|
-
required: false,
|
28
|
-
default: 6379
|
29
|
-
|
30
|
-
option :password,
|
31
|
-
short: '-P PASSWORD',
|
32
|
-
long: '--password PASSWORD',
|
33
|
-
description: 'Redis Password to connect with'
|
34
|
-
|
35
|
-
option :conn_failure_status,
|
36
|
-
long: '--conn-failure-status EXIT_STATUS',
|
37
|
-
description: 'Returns the following exit status for Redis connection failures',
|
38
|
-
default: 'unknown',
|
39
|
-
in: %w(unknown warning critical)
|
40
|
-
|
41
|
-
option :timeout,
|
42
|
-
short: '-t TIMEOUT',
|
43
|
-
long: '--timeout TIMEOUT',
|
44
|
-
description: 'Redis connection timeout',
|
45
|
-
required: false,
|
46
|
-
proc: proc(&:to_i),
|
47
|
-
default: 5
|
10
|
+
include RedisClientOptions
|
48
11
|
|
49
12
|
def run
|
50
|
-
|
51
|
-
{ path: socket }
|
52
|
-
else
|
53
|
-
{ host: config[:host], port: config[:port], timeout: config[:timeout] }
|
54
|
-
end
|
55
|
-
|
56
|
-
options[:password] = config[:password] if config[:password]
|
57
|
-
redis = Redis.new(options)
|
13
|
+
redis = Redis.new(default_redis_options)
|
58
14
|
|
59
15
|
if redis.info.fetch('role') == 'master'
|
60
16
|
ok 'This redis server is master'
|
@@ -67,8 +23,8 @@ class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
|
67
23
|
critical msg
|
68
24
|
end
|
69
25
|
rescue KeyError
|
70
|
-
critical "Redis server on #{
|
26
|
+
critical "Redis server on #{redis_endpoint} is not master and does not have master_link_status"
|
71
27
|
rescue
|
72
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
28
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
73
29
|
end
|
74
30
|
end
|
@@ -11,8 +11,11 @@
|
|
11
11
|
|
12
12
|
require 'sensu-plugin/metric/cli'
|
13
13
|
require 'redis'
|
14
|
+
require_relative '../lib/redis_client_options'
|
14
15
|
|
15
16
|
class Redis2Graphite < Sensu::Plugin::Metric::CLI::Graphite
|
17
|
+
include RedisClientOptions
|
18
|
+
|
16
19
|
# redis.c - sds genRedisInfoString(char *section)
|
17
20
|
SKIP_KEYS_REGEX = [
|
18
21
|
'^role',
|
@@ -47,77 +50,20 @@ class Redis2Graphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
47
50
|
'used_memory_rss_human'
|
48
51
|
].freeze
|
49
52
|
|
50
|
-
option :socket,
|
51
|
-
short: '-s SOCKET',
|
52
|
-
long: '--socket SOCKET',
|
53
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
54
|
-
required: false
|
55
|
-
|
56
|
-
option :host,
|
57
|
-
short: '-h HOST',
|
58
|
-
long: '--host HOST',
|
59
|
-
description: 'Redis Host to connect to',
|
60
|
-
default: '127.0.0.1'
|
61
|
-
|
62
|
-
option :port,
|
63
|
-
short: '-p PORT',
|
64
|
-
long: '--port PORT',
|
65
|
-
description: 'Redis Port to connect to',
|
66
|
-
proc: proc(&:to_i),
|
67
|
-
default: 6379
|
68
|
-
|
69
|
-
option :password,
|
70
|
-
short: '-P PASSWORD',
|
71
|
-
long: '--password PASSWORD',
|
72
|
-
description: 'Redis Password to connect with'
|
73
|
-
|
74
53
|
option :scheme,
|
75
54
|
description: 'Metric naming scheme, text to prepend to metric',
|
76
55
|
short: '-S SCHEME',
|
77
56
|
long: '--scheme SCHEME',
|
78
57
|
default: "#{Socket.gethostname}.redis"
|
79
58
|
|
80
|
-
option :timeout,
|
81
|
-
description: 'Timeout to connect to redis host',
|
82
|
-
short: '-t TIMEOUT',
|
83
|
-
long: '--timeout TIMEOUT',
|
84
|
-
proc: proc(&:to_i),
|
85
|
-
default: Redis::Client::DEFAULTS[:timeout]
|
86
|
-
|
87
|
-
option :reconnect_attempts,
|
88
|
-
description: 'Reconnect attempts to redis host',
|
89
|
-
short: '-r ATTEMPTS',
|
90
|
-
long: '--reconnect ATTEMPTS',
|
91
|
-
proc: proc(&:to_i),
|
92
|
-
default: Redis::Client::DEFAULTS[:reconnect_attempts]
|
93
|
-
|
94
59
|
option :skip_keys_regex,
|
95
60
|
description: 'a comma seperated list of keys to be skipped',
|
96
61
|
short: '-k KEYS',
|
97
62
|
long: '--skipkeys KEYS',
|
98
63
|
default: nil
|
99
64
|
|
100
|
-
option :conn_failure_status,
|
101
|
-
long: '--conn-failure-status EXIT_STATUS',
|
102
|
-
description: 'Returns the following exit status for Redis connection failures',
|
103
|
-
default: 'unknown',
|
104
|
-
in: %w(unknown warning critical)
|
105
|
-
|
106
65
|
def run
|
107
|
-
|
108
|
-
timeout: config[:timeout],
|
109
|
-
reconnect_attempts: config[:reconnect_attempts]
|
110
|
-
}
|
111
|
-
|
112
|
-
if config[:socket]
|
113
|
-
options[:path] = config[:socket]
|
114
|
-
else
|
115
|
-
options[:host] = config[:host]
|
116
|
-
options[:port] = config[:port]
|
117
|
-
end
|
118
|
-
|
119
|
-
options[:password] = config[:password] if config[:password]
|
120
|
-
redis = Redis.new(options)
|
66
|
+
redis = Redis.new(default_redis_options)
|
121
67
|
skip_keys = if !config[:skip_keys_regex].nil?
|
122
68
|
config[:skip_keys_regex].split(',')
|
123
69
|
else
|
@@ -149,6 +95,6 @@ class Redis2Graphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
149
95
|
|
150
96
|
ok
|
151
97
|
rescue
|
152
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
98
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
153
99
|
end
|
154
100
|
end
|
data/bin/metrics-redis-llen.rb
CHANGED
@@ -9,39 +9,10 @@
|
|
9
9
|
|
10
10
|
require 'sensu-plugin/metric/cli'
|
11
11
|
require 'redis'
|
12
|
+
require_relative '../lib/redis_client_options'
|
12
13
|
|
13
14
|
class RedisListLengthMetric < Sensu::Plugin::Metric::CLI::Graphite
|
14
|
-
|
15
|
-
short: '-s SOCKET',
|
16
|
-
long: '--socket SOCKET',
|
17
|
-
description: 'Redis socket to connect to (overrides Host and Port)',
|
18
|
-
required: false
|
19
|
-
|
20
|
-
option :host,
|
21
|
-
short: '-h HOST',
|
22
|
-
long: '--host HOST',
|
23
|
-
description: 'Redis Host to connect to',
|
24
|
-
default: '127.0.0.1'
|
25
|
-
|
26
|
-
option :port,
|
27
|
-
short: '-p PORT',
|
28
|
-
long: '--port PORT',
|
29
|
-
description: 'Redis Port to connect to',
|
30
|
-
proc: proc(&:to_i),
|
31
|
-
default: 6379
|
32
|
-
|
33
|
-
option :database,
|
34
|
-
short: '-n DATABASE',
|
35
|
-
long: '--dbnumber DATABASE',
|
36
|
-
description: 'Redis database number to connect to',
|
37
|
-
proc: proc(&:to_i),
|
38
|
-
required: false,
|
39
|
-
default: 0
|
40
|
-
|
41
|
-
option :password,
|
42
|
-
short: '-P PASSWORD',
|
43
|
-
long: '--password PASSWORD',
|
44
|
-
description: 'Redis Password to connect with'
|
15
|
+
include RedisClientOptions
|
45
16
|
|
46
17
|
option :scheme,
|
47
18
|
description: 'Metric naming scheme, text to prepend to metric',
|
@@ -55,29 +26,15 @@ class RedisListLengthMetric < Sensu::Plugin::Metric::CLI::Graphite
|
|
55
26
|
description: 'Comma separated list of keys to check',
|
56
27
|
required: true
|
57
28
|
|
58
|
-
option :conn_failure_status,
|
59
|
-
long: '--conn-failure-status EXIT_STATUS',
|
60
|
-
description: 'Returns the following exit status for Redis connection failures',
|
61
|
-
default: 'unknown',
|
62
|
-
in: %w(unknown warning critical)
|
63
|
-
|
64
29
|
def run
|
65
|
-
|
66
|
-
options = if config[:socket]
|
67
|
-
{ path: socket }
|
68
|
-
else
|
69
|
-
{ host: config[:host], port: config[:port] }
|
70
|
-
end
|
71
|
-
|
72
|
-
options[:db] = config[:database]
|
73
|
-
options[:password] = config[:password] if config[:password]
|
74
|
-
redis = Redis.new(options)
|
30
|
+
redis = Redis.new(default_redis_options)
|
75
31
|
|
32
|
+
redis_keys = config[:key].split(',')
|
76
33
|
redis_keys.each do |key|
|
77
34
|
output "#{config[:scheme]}.#{key}.items", redis.llen(key)
|
78
35
|
end
|
79
36
|
ok
|
80
37
|
rescue
|
81
|
-
send(config[:conn_failure_status], "Could not connect to Redis server on #{
|
38
|
+
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
|
82
39
|
end
|
83
40
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require 'sensu-plugin/metric/cli'
|
3
|
+
|
4
|
+
module RedisClientOptions
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.class_eval do
|
8
|
+
_configure_options
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_redis_options
|
13
|
+
opts = {}
|
14
|
+
opts[:password] = config[:password] if config[:password]
|
15
|
+
opts[:timeout] = config[:timeout] if config[:timeout]
|
16
|
+
opts[:db] = config[:database] if config[:database]
|
17
|
+
|
18
|
+
if config[:socket]
|
19
|
+
opts[:path] = config[:socket]
|
20
|
+
else
|
21
|
+
opts[:host] = config[:host]
|
22
|
+
opts[:port] = config[:port]
|
23
|
+
end
|
24
|
+
opts
|
25
|
+
end
|
26
|
+
|
27
|
+
def redis_endpoint
|
28
|
+
if config[:socket]
|
29
|
+
"unix://#{config[:socket]}"
|
30
|
+
else
|
31
|
+
"#{config[:host]}:#{config[:port]}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module ClassMethods
|
36
|
+
def _configure_options
|
37
|
+
option :socket,
|
38
|
+
short: '-s SOCKET',
|
39
|
+
long: '--socket SOCKET',
|
40
|
+
description: 'Redis socket to connect to (overrides Host and Port)',
|
41
|
+
required: false
|
42
|
+
|
43
|
+
option :host,
|
44
|
+
short: '-h HOST',
|
45
|
+
long: '--host HOST',
|
46
|
+
description: 'Redis Host to connect to',
|
47
|
+
required: false,
|
48
|
+
default: Redis::Client::DEFAULTS[:host]
|
49
|
+
|
50
|
+
option :port,
|
51
|
+
short: '-p PORT',
|
52
|
+
long: '--port PORT',
|
53
|
+
description: 'Redis Port to connect to',
|
54
|
+
proc: proc(&:to_i),
|
55
|
+
required: false,
|
56
|
+
default: Redis::Client::DEFAULTS[:port]
|
57
|
+
|
58
|
+
option :database,
|
59
|
+
short: '-n DATABASE',
|
60
|
+
long: '--dbnumber DATABASE',
|
61
|
+
description: 'Redis database number to connect to',
|
62
|
+
proc: proc(&:to_i),
|
63
|
+
required: false,
|
64
|
+
default: Redis::Client::DEFAULTS[:db]
|
65
|
+
|
66
|
+
option :password,
|
67
|
+
short: '-P PASSWORD',
|
68
|
+
long: '--password PASSWORD',
|
69
|
+
description: 'Redis Password to connect with'
|
70
|
+
|
71
|
+
option :conn_failure_status,
|
72
|
+
long: '--conn-failure-status EXIT_STATUS',
|
73
|
+
description: 'Returns the following exit status for Redis connection failures',
|
74
|
+
default: 'critical',
|
75
|
+
in: %w(unknown warning critical)
|
76
|
+
|
77
|
+
option :timeout,
|
78
|
+
short: '-t TIMEOUT',
|
79
|
+
long: '--timeout TIMEOUT',
|
80
|
+
description: 'Redis connection timeout',
|
81
|
+
proc: proc(&:to_f),
|
82
|
+
required: false,
|
83
|
+
default: Redis::Client::DEFAULTS[:timeout]
|
84
|
+
|
85
|
+
option :reconnect_attempts,
|
86
|
+
description: 'Reconnect attempts to Redis host',
|
87
|
+
short: '-r ATTEMPTS',
|
88
|
+
long: '--reconnect ATTEMPTS',
|
89
|
+
proc: proc(&:to_i),
|
90
|
+
default: Redis::Client::DEFAULTS[:reconnect_attempts]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -229,14 +229,14 @@ description: |-
|
|
229
229
|
email: "<sensu-users@googlegroups.com>"
|
230
230
|
executables:
|
231
231
|
- check-redis-memory.rb
|
232
|
+
- metrics-redis-llen.rb
|
233
|
+
- check-redis-ping.rb
|
234
|
+
- check-redis-memory-percentage.rb
|
232
235
|
- check-redis-info.rb
|
233
|
-
- check-redis-
|
236
|
+
- check-redis-slave-status.rb
|
234
237
|
- check-redis-keys.rb
|
235
|
-
- check-redis-memory-percentage.rb
|
236
|
-
- check-redis-ping.rb
|
237
|
-
- metrics-redis-llen.rb
|
238
238
|
- metrics-redis-graphite.rb
|
239
|
-
- check-redis-
|
239
|
+
- check-redis-list-length.rb
|
240
240
|
extensions: []
|
241
241
|
extra_rdoc_files: []
|
242
242
|
files:
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- bin/check-redis-slave-status.rb
|
253
253
|
- bin/metrics-redis-graphite.rb
|
254
254
|
- bin/metrics-redis-llen.rb
|
255
|
+
- lib/redis_client_options.rb
|
255
256
|
- lib/sensu-plugins-redis.rb
|
256
257
|
- lib/sensu-plugins-redis/version.rb
|
257
258
|
homepage: https://github.com/sensu-plugins/sensu-plugins-redis
|
@@ -280,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
283
|
rubyforge_project:
|
283
|
-
rubygems_version: 2.
|
284
|
+
rubygems_version: 2.5.2.1
|
284
285
|
signing_key:
|
285
286
|
specification_version: 4
|
286
287
|
summary: Sensu plugins for working with redis
|