sensu-plugins-redis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/bin/check-redis-info.rb +72 -0
- data/bin/check-redis-list-length.rb +83 -0
- data/bin/check-redis-memory.rb +78 -0
- data/bin/check-redis-ping.rb +73 -0
- data/bin/check-redis-slave-status.rb +49 -0
- data/bin/metrics-redis-graphite.rb +91 -0
- data/bin/metrics-redis-llen.rb +52 -0
- data/lib/sensu-plugins-redis.rb +2 -0
- data/lib/sensu-plugins-redis/version.rb +13 -0
- metadata +237 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd7d9868c71a4cedb6a22be1ba6b190fbd688ce5
|
4
|
+
data.tar.gz: 1c23018a8251f86ede5c24d52b96c60391545247
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e24ff19b383c314f4133ae93807337a08b0296f56c7f997c9c1b455075baa71d0ff3099c55ed4242e1cd765589f83e33e879b56821cb001c9667964890662c1
|
7
|
+
data.tar.gz: 2926376d198d839b6f54adf8c2a51f10ba8522c49fb5d7b4ad7879ab3c47626533a14075598c584c71232d8cac2f57e01b13615ca204dcbbb4efe48c4f606083
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
|
+
|
6
|
+
## Unreleased][unreleased]
|
7
|
+
|
8
|
+
## 0.0.1 - 2015-05-31
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## Sensu-Plugins-redis
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-redis.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-redis)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-redis.svg)](http://badge.fury.io/rb/sensu-plugins-redis)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-redis/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-redis)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-redis/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-redis)
|
7
|
+
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-redis.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-redis)
|
8
|
+
[![Codeship Status for sensu-plugins/sensu-plugins-redis](https://codeship.com/projects/e211de50-e89a-0132-adeb-62885e5c211b/status?branch=master)](https://codeship.com/projects/82841)
|
9
|
+
|
10
|
+
## Functionality
|
11
|
+
|
12
|
+
## Files
|
13
|
+
* bin/check-redis-info.rb
|
14
|
+
* bin/check-redis-list-length.rb
|
15
|
+
* bin/check-redis-memory.rb
|
16
|
+
* bin/check-redis-ping.rb
|
17
|
+
* bin/check-redis-slave-status.rb
|
18
|
+
* bin/extension-redis-output.rb
|
19
|
+
* bin/metrics-redis-graphite.rb
|
20
|
+
* bin/metrics-redis-llen.rb
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
[Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
|
27
|
+
|
28
|
+
## Notes
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Checks checks variables from redis INFO http://redis.io/commands/INFO
|
4
|
+
#
|
5
|
+
# ===
|
6
|
+
#
|
7
|
+
# Depends on redis gem
|
8
|
+
# gem install redis
|
9
|
+
#
|
10
|
+
# ===
|
11
|
+
#
|
12
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
13
|
+
# for details.
|
14
|
+
#
|
15
|
+
# Heavily inspired in check-redis-slave-status.rb
|
16
|
+
# https://github.com/sensu/sensu-community-plugins/blob/master/plugins/redis/check-redis-slave-status.rb
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'sensu-plugin/check/cli'
|
20
|
+
require 'redis'
|
21
|
+
|
22
|
+
class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
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 :password,
|
39
|
+
short: '-P PASSWORD',
|
40
|
+
long: '--password PASSWORD',
|
41
|
+
description: 'Redis Password to connect with'
|
42
|
+
|
43
|
+
option :redis_info_key,
|
44
|
+
short: '-K VALUE',
|
45
|
+
long: '--redis-info-key KEY',
|
46
|
+
description: 'Redis info key to monitor',
|
47
|
+
required: false,
|
48
|
+
default: 'role'
|
49
|
+
|
50
|
+
option :redis_info_value,
|
51
|
+
short: '-V VALUE',
|
52
|
+
long: '--redis-info-key-value VALUE',
|
53
|
+
description: 'Redis info key value to trigger alarm',
|
54
|
+
required: false,
|
55
|
+
default: 'master'
|
56
|
+
|
57
|
+
def run
|
58
|
+
options = { host: config[:host], port: config[:port] }
|
59
|
+
options[:password] = config[:password] if config[:password]
|
60
|
+
redis = Redis.new(options)
|
61
|
+
|
62
|
+
if redis.info.fetch("#{config[:redis_info_key]}") == "#{config[:redis_info_value]}"
|
63
|
+
ok "Redis #{config[:redis_info_key]} is #{config[:redis_info_value]}"
|
64
|
+
else
|
65
|
+
critical "Redis #{config[:redis_info_key]} is #{redis.info.fetch("#{config[:redis_info_key]}")}!"
|
66
|
+
end
|
67
|
+
|
68
|
+
rescue
|
69
|
+
message "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
|
70
|
+
exit 1
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Checks number of items in a Redis list key
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# Depends on redis gem
|
7
|
+
# gem install redis
|
8
|
+
#
|
9
|
+
# Copyright (c) 2013, Piavlo <lolitushka@gmail.com>
|
10
|
+
#
|
11
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
12
|
+
# for details.
|
13
|
+
|
14
|
+
require 'sensu-plugin/check/cli'
|
15
|
+
require 'redis'
|
16
|
+
|
17
|
+
class RedisListLengthCheck < Sensu::Plugin::Check::CLI
|
18
|
+
option :host,
|
19
|
+
short: '-h HOST',
|
20
|
+
long: '--host HOST',
|
21
|
+
description: 'Redis Host to connect to',
|
22
|
+
required: false,
|
23
|
+
default: '127.0.0.1'
|
24
|
+
|
25
|
+
option :port,
|
26
|
+
short: '-p PORT',
|
27
|
+
long: '--port PORT',
|
28
|
+
description: 'Redis Port to connect to',
|
29
|
+
proc: proc(&:to_i),
|
30
|
+
required: false,
|
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'
|
45
|
+
|
46
|
+
option :warn,
|
47
|
+
short: '-w COUNT',
|
48
|
+
long: '--warning COUNT',
|
49
|
+
description: 'COUNT warning threshold for number of items in Redis list key',
|
50
|
+
proc: proc(&:to_i),
|
51
|
+
required: true
|
52
|
+
|
53
|
+
option :crit,
|
54
|
+
short: '-c COUNT',
|
55
|
+
long: '--critical COUNT',
|
56
|
+
description: 'COUNT critical threshold for number of items in Redis list key',
|
57
|
+
proc: proc(&:to_i),
|
58
|
+
required: true
|
59
|
+
|
60
|
+
option :key,
|
61
|
+
short: '-k KEY',
|
62
|
+
long: '--key KEY',
|
63
|
+
description: 'Redis list KEY to check',
|
64
|
+
required: true
|
65
|
+
|
66
|
+
def run
|
67
|
+
options = { host: config[:host], port: config[:port], db: config[:database] }
|
68
|
+
options[:password] = config[:password] if config[:password]
|
69
|
+
redis = Redis.new(options)
|
70
|
+
|
71
|
+
length = redis.llen(config[:key])
|
72
|
+
|
73
|
+
if length >= config[:crit]
|
74
|
+
critical "Redis list #{config[:key]} length is above the CRITICAL limit: #{length} length / #{config[:crit]} limit"
|
75
|
+
elsif length >= config[:warn]
|
76
|
+
warning "Redis list #{config[:key]} length is above the WARNING limit: #{length} length / #{config[:warn]} limit"
|
77
|
+
else
|
78
|
+
ok "Redis list #{config[:key]} length is below thresholds"
|
79
|
+
end
|
80
|
+
rescue
|
81
|
+
unknown "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Checks Redis INFO stats and limits values
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# Copyright (c) 2012, Panagiotis Papadomitsos <pj@ezgr.net>
|
7
|
+
#
|
8
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
9
|
+
# for details.
|
10
|
+
|
11
|
+
require 'sensu-plugin/check/cli'
|
12
|
+
require 'redis'
|
13
|
+
|
14
|
+
class RedisChecks < Sensu::Plugin::Check::CLI
|
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 :warn_mem,
|
36
|
+
short: '-w KB',
|
37
|
+
long: '--warnmem KB',
|
38
|
+
description: "Allocated KB of Redis memory on which we'll issue a WARNING",
|
39
|
+
proc: proc(&:to_i),
|
40
|
+
required: true
|
41
|
+
|
42
|
+
option :crit_mem,
|
43
|
+
short: '-c KB',
|
44
|
+
long: '--critmem KB',
|
45
|
+
description: "Allocated KB of Redis memory on which we'll issue a CRITICAL",
|
46
|
+
proc: proc(&:to_i),
|
47
|
+
required: true
|
48
|
+
|
49
|
+
option :crit_conn,
|
50
|
+
long: '--crit-conn-failure',
|
51
|
+
boolean: true,
|
52
|
+
description: 'Critical instead of warning on connection failure',
|
53
|
+
default: false
|
54
|
+
|
55
|
+
def run
|
56
|
+
options = { host: config[:host], port: config[:port] }
|
57
|
+
options[:password] = config[:password] if config[:password]
|
58
|
+
redis = Redis.new(options)
|
59
|
+
|
60
|
+
used_memory = redis.info.fetch('used_memory').to_i.div(1024)
|
61
|
+
warn_memory = config[:warn_mem]
|
62
|
+
crit_memory = config[:crit_mem]
|
63
|
+
if used_memory >= crit_memory
|
64
|
+
critical "Redis running on #{config[:host]}:#{config[:port]} is above the CRITICAL limit: #{used_memory} KB used / #{crit_memory} KB limit"
|
65
|
+
elsif used_memory >= warn_memory
|
66
|
+
warning "Redis running on #{config[:host]}:#{config[:port]} is above the WARNING limit: #{used_memory} KB used / #{warn_memory} KB limit"
|
67
|
+
else
|
68
|
+
ok 'Redis memory usage is below defined limits'
|
69
|
+
end
|
70
|
+
rescue
|
71
|
+
message = "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
|
72
|
+
if config[:crit_conn]
|
73
|
+
critical message
|
74
|
+
else
|
75
|
+
warning message
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# <script name>
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Runs Redis ping command to see if Redis is alive
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: redis
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# check-redis-ping.rb -h redis.example.com -p 6380 -P secret
|
20
|
+
#
|
21
|
+
# NOTE:
|
22
|
+
# Heavily inspired by check-redis-info.rb
|
23
|
+
# https://github.com/sensu/sensu-community-plugins/blob/master/plugins/redis/check-redis-info.rb
|
24
|
+
#
|
25
|
+
# LICENSE:
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'redis'
|
32
|
+
|
33
|
+
class RedisPing < Sensu::Plugin::Check::CLI
|
34
|
+
option :host,
|
35
|
+
short: '-h HOST',
|
36
|
+
long: '--host HOST',
|
37
|
+
description: 'Redis Host to connect to',
|
38
|
+
required: false,
|
39
|
+
default: '127.0.0.1'
|
40
|
+
|
41
|
+
option :port,
|
42
|
+
short: '-p PORT',
|
43
|
+
long: '--port PORT',
|
44
|
+
description: 'Redis Port to connect to',
|
45
|
+
proc: proc(&:to_i),
|
46
|
+
required: false,
|
47
|
+
default: 6379
|
48
|
+
|
49
|
+
option :password,
|
50
|
+
short: '-P PASSWORD',
|
51
|
+
long: '--password PASSWORD',
|
52
|
+
description: 'Redis Password to connect with'
|
53
|
+
|
54
|
+
def redis_options
|
55
|
+
{
|
56
|
+
host: config[:host],
|
57
|
+
port: config[:port],
|
58
|
+
password: config[:password]
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
if Redis.new(redis_options).ping == 'PONG'
|
64
|
+
ok 'Redis is alive'
|
65
|
+
else
|
66
|
+
critical 'Redis did not respond to the ping command'
|
67
|
+
end
|
68
|
+
|
69
|
+
rescue
|
70
|
+
message "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Checks Redis Slave Replication
|
4
|
+
|
5
|
+
require 'sensu-plugin/check/cli'
|
6
|
+
require 'redis'
|
7
|
+
|
8
|
+
class RedisSlaveCheck < Sensu::Plugin::Check::CLI
|
9
|
+
option :host,
|
10
|
+
short: '-h HOST',
|
11
|
+
long: '--host HOST',
|
12
|
+
description: 'Redis Host to connect to',
|
13
|
+
required: false,
|
14
|
+
default: '127.0.0.1'
|
15
|
+
|
16
|
+
option :port,
|
17
|
+
short: '-p PORT',
|
18
|
+
long: '--port PORT',
|
19
|
+
description: 'Redis Port to connect to',
|
20
|
+
proc: proc(&:to_i),
|
21
|
+
required: false,
|
22
|
+
default: 6379
|
23
|
+
|
24
|
+
option :password,
|
25
|
+
short: '-P PASSWORD',
|
26
|
+
long: '--password PASSWORD',
|
27
|
+
description: 'Redis Password to connect with'
|
28
|
+
|
29
|
+
def run
|
30
|
+
options = { host: config[:host], port: config[:port] }
|
31
|
+
options[:password] = config[:password] if config[:password]
|
32
|
+
redis = Redis.new(options)
|
33
|
+
|
34
|
+
if redis.info.fetch('master_link_status') == 'up'
|
35
|
+
ok 'The redis master links status is up!'
|
36
|
+
else
|
37
|
+
msg = ''
|
38
|
+
msg += "The redis master link status to: #{redis.info.fetch('master_host')} is down!"
|
39
|
+
msg += " It has been down for #{redis.info.fetch('master_link_down_since_seconds')}."
|
40
|
+
critical msg
|
41
|
+
end
|
42
|
+
|
43
|
+
rescue KeyError
|
44
|
+
critical "Redis server on #{config[:host]}:#{config[:port]} is master"
|
45
|
+
|
46
|
+
rescue
|
47
|
+
critical "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Push Redis INFO stats into graphite
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# Copyright 2012 Pete Shima <me@peteshima.com>
|
7
|
+
# Brian Racer <bracer@gmail.com>
|
8
|
+
#
|
9
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
10
|
+
# for details.
|
11
|
+
|
12
|
+
require 'sensu-plugin/metric/cli'
|
13
|
+
require 'redis'
|
14
|
+
|
15
|
+
class Redis2Graphite < Sensu::Plugin::Metric::CLI::Graphite
|
16
|
+
# redis.c - sds genRedisInfoString(char *section)
|
17
|
+
SKIP_KEYS_REGEX = ['gcc_version', 'master_host', 'master_link_status',
|
18
|
+
'master_port', 'mem_allocator', 'multiplexing_api', 'process_id',
|
19
|
+
'redis_git_dirty', 'redis_git_sha1', 'redis_version', '^role',
|
20
|
+
'run_id', '^slave', 'used_memory_human', 'used_memory_peak_human',
|
21
|
+
'redis_mode', 'os', 'arch_bits', 'tcp_port',
|
22
|
+
'rdb_last_bgsave_status', 'aof_last_bgrewrite_status', 'config_file',
|
23
|
+
'redis_build_id']
|
24
|
+
|
25
|
+
option :host,
|
26
|
+
short: '-h HOST',
|
27
|
+
long: '--host HOST',
|
28
|
+
description: 'Redis Host to connect to',
|
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
|
+
default: 6379
|
37
|
+
|
38
|
+
option :password,
|
39
|
+
short: '-P PASSWORD',
|
40
|
+
long: '--password PASSWORD',
|
41
|
+
description: 'Redis Password to connect with'
|
42
|
+
|
43
|
+
option :scheme,
|
44
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
45
|
+
short: '-s SCHEME',
|
46
|
+
long: '--scheme SCHEME',
|
47
|
+
default: "#{Socket.gethostname}.redis"
|
48
|
+
|
49
|
+
option :timeout,
|
50
|
+
description: 'Timeout to connect to redis host',
|
51
|
+
short: '-t TIMEOUT',
|
52
|
+
long: '--timeout TIMEOUT',
|
53
|
+
proc: proc(&:to_i),
|
54
|
+
default: Redis::Client::DEFAULTS[:timeout]
|
55
|
+
|
56
|
+
option :reconnect_attempts,
|
57
|
+
description: 'Reconnect attempts to redis host',
|
58
|
+
short: '-r ATTEMPTS',
|
59
|
+
long: '--reconnect ATTEMPTS',
|
60
|
+
proc: proc(&:to_i),
|
61
|
+
default: Redis::Client::DEFAULTS[:reconnect_attempts]
|
62
|
+
|
63
|
+
def run
|
64
|
+
options = {
|
65
|
+
host: config[:host],
|
66
|
+
port: config[:port],
|
67
|
+
timeout: config[:timeout],
|
68
|
+
reconnect_attempts: config[:reconnect_attempts]
|
69
|
+
}
|
70
|
+
options[:password] = config[:password] if config[:password]
|
71
|
+
redis = Redis.new(options)
|
72
|
+
|
73
|
+
redis.info.each do |k, v|
|
74
|
+
next unless SKIP_KEYS_REGEX.map { |re| k.match(/#{re}/) }.compact.empty?
|
75
|
+
|
76
|
+
# "db0"=>"keys=123,expires=12"
|
77
|
+
if k =~ /^db/
|
78
|
+
keys, expires = v.split(',')
|
79
|
+
keys.gsub!('keys=', '')
|
80
|
+
expires.gsub!('expires=', '')
|
81
|
+
|
82
|
+
output "#{config[:scheme]}.#{k}.keys", keys
|
83
|
+
output "#{config[:scheme]}.#{k}.expires", expires
|
84
|
+
else
|
85
|
+
output "#{config[:scheme]}.#{k}", v
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
ok
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Get the length of a list and push it to graphite
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
8
|
+
# for details.
|
9
|
+
|
10
|
+
require 'sensu-plugin/metric/cli'
|
11
|
+
require 'redis'
|
12
|
+
|
13
|
+
class RedisListLengthMetric < Sensu::Plugin::Metric::CLI::Graphite
|
14
|
+
option :host,
|
15
|
+
short: '-h HOST',
|
16
|
+
long: '--host HOST',
|
17
|
+
description: 'Redis Host to connect to',
|
18
|
+
default: '127.0.0.1'
|
19
|
+
|
20
|
+
option :port,
|
21
|
+
short: '-p PORT',
|
22
|
+
long: '--port PORT',
|
23
|
+
description: 'Redis Port to connect to',
|
24
|
+
proc: proc(&:to_i),
|
25
|
+
default: 6379
|
26
|
+
|
27
|
+
option :password,
|
28
|
+
short: '-P PASSWORD',
|
29
|
+
long: '--password PASSWORD',
|
30
|
+
description: 'Redis Password to connect with'
|
31
|
+
|
32
|
+
option :scheme,
|
33
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
34
|
+
short: '-s SCHEME',
|
35
|
+
long: '--scheme SCHEME',
|
36
|
+
default: "#{Socket.gethostname}.redis"
|
37
|
+
|
38
|
+
option :key,
|
39
|
+
short: '-k KEY',
|
40
|
+
long: '--key KEY',
|
41
|
+
description: 'Redis list KEY to check',
|
42
|
+
required: true
|
43
|
+
|
44
|
+
def run
|
45
|
+
options = { host: config[:host], port: config[:port] }
|
46
|
+
options[:password] = config[:password] if config[:password]
|
47
|
+
redis = Redis.new(options)
|
48
|
+
|
49
|
+
output "#{config[:scheme]}.#{config[:key]}.items", redis.llen(config[:key])
|
50
|
+
ok
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sensu-Plugins and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sensu-plugin
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: redis
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.2.1
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.2.1
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: codeclimate-test-reporter
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.4'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.4'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rubocop
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.30'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.30'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rspec
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.1'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.1'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: bundler
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.7'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.7'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rake
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '10.0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '10.0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: github-markup
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '1.3'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.3'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: redcarpet
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.2'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '3.2'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: yard
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0.8'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0.8'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: pry
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0.10'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0.10'
|
189
|
+
description: Sensu plugins for redis
|
190
|
+
email: "<sensu-users@googlegroups.com>"
|
191
|
+
executables: []
|
192
|
+
extensions: []
|
193
|
+
extra_rdoc_files: []
|
194
|
+
files:
|
195
|
+
- CHANGELOG.md
|
196
|
+
- LICENSE
|
197
|
+
- README.md
|
198
|
+
- bin/check-redis-info.rb
|
199
|
+
- bin/check-redis-list-length.rb
|
200
|
+
- bin/check-redis-memory.rb
|
201
|
+
- bin/check-redis-ping.rb
|
202
|
+
- bin/check-redis-slave-status.rb
|
203
|
+
- bin/metrics-redis-graphite.rb
|
204
|
+
- bin/metrics-redis-llen.rb
|
205
|
+
- lib/sensu-plugins-redis.rb
|
206
|
+
- lib/sensu-plugins-redis/version.rb
|
207
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-redis
|
208
|
+
licenses:
|
209
|
+
- MIT
|
210
|
+
metadata:
|
211
|
+
maintainer: "@mattyjones"
|
212
|
+
development_status: active
|
213
|
+
production_status: unstable - testing recommended
|
214
|
+
release_draft: 'false'
|
215
|
+
release_prerelease: 'false'
|
216
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
217
|
+
in /etc/default/sensu
|
218
|
+
rdoc_options: []
|
219
|
+
require_paths:
|
220
|
+
- lib
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: 1.9.3
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 2.4.6
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: Sensu plugins for working with redis
|
237
|
+
test_files: []
|
metadata.gz.sig
ADDED