sensu-plugins-edgelab 1.5.5 → 1.6.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.
- checksums.yaml +4 -4
- data/bin/metrics-redis-key-pattern.rb +108 -0
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849e633aa8b13087335f8d19c290c7a49ad2f447
|
4
|
+
data.tar.gz: d7465d881db023f2169c7ac29d08d384724121b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7067c3961f1ebd1f356aa490f7f48f27ab8fcb9ebe259c51bd4bde6dd85ed189120df508af4a08bdadcf14c96d25b078f5880a35452bb8984e4b77e57ff8c2b
|
7
|
+
data.tar.gz: 42814394b676ee6534e8e4ab64799b3b70b2141bac154102c5720c6ea53d95be964fae841711e77c2139469af8fc47275246bdf7d776fa45f28618590adffe21
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-redis-key-pattern
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Count number of keys by a pattern.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric-data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux, Windows, BSD, Solaris, etc
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: redis
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# Jonathan Ballet <jballet@edgelab.ch>
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
25
|
+
# for details.
|
26
|
+
|
27
|
+
require 'sensu-plugin/metric/cli'
|
28
|
+
require 'redis'
|
29
|
+
|
30
|
+
class RedisKeyPatternMetric < Sensu::Plugin::Metric::CLI::Graphite
|
31
|
+
option :host,
|
32
|
+
short: '-h HOST',
|
33
|
+
long: '--host HOST',
|
34
|
+
description: 'Redis Host to connect to',
|
35
|
+
default: '127.0.0.1'
|
36
|
+
|
37
|
+
option :port,
|
38
|
+
short: '-p PORT',
|
39
|
+
long: '--port PORT',
|
40
|
+
description: 'Redis Port to connect to',
|
41
|
+
proc: proc(&:to_i),
|
42
|
+
default: 6379
|
43
|
+
|
44
|
+
option :password,
|
45
|
+
short: '-P PASSWORD',
|
46
|
+
long: '--password PASSWORD',
|
47
|
+
description: 'Redis Password to connect with'
|
48
|
+
|
49
|
+
option :scheme,
|
50
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
51
|
+
short: '-s SCHEME',
|
52
|
+
long: '--scheme SCHEME',
|
53
|
+
default: "#{Socket.gethostname}.redis"
|
54
|
+
|
55
|
+
option :nb_db,
|
56
|
+
description: 'Number of databases to scan (default 16)',
|
57
|
+
short: '-n NUM_DATABASES',
|
58
|
+
long: '--number-databases NUM_DATABASES',
|
59
|
+
proc: proc(&:to_i),
|
60
|
+
default: 16
|
61
|
+
|
62
|
+
option :segments,
|
63
|
+
description: 'Number of key segments to measure',
|
64
|
+
long: '--segments SEGMENTS',
|
65
|
+
proc: proc(&:to_i),
|
66
|
+
default: 1
|
67
|
+
|
68
|
+
option :key_slice,
|
69
|
+
description: 'Slice where to split the key from',
|
70
|
+
long: '--key-slice KEY_SLICE',
|
71
|
+
proc: proc(&:to_i),
|
72
|
+
default: 30
|
73
|
+
|
74
|
+
option :split_char,
|
75
|
+
description: 'Which character to split they key',
|
76
|
+
long: '--split-char SPLIT_CHAR',
|
77
|
+
default: ':'
|
78
|
+
|
79
|
+
def run
|
80
|
+
options = { host: config[:host], port: config[:port] }
|
81
|
+
options[:password] = config[:password] if config[:password]
|
82
|
+
redis = Redis.new(options)
|
83
|
+
|
84
|
+
(0..(config[:nb_db] - 1)).each do |db|
|
85
|
+
begin
|
86
|
+
redis.select(db)
|
87
|
+
rescue Redis::CommandError
|
88
|
+
# Selected database doesn't exist, it's probably we iterated over all
|
89
|
+
# the databases of this Redis instance.
|
90
|
+
break
|
91
|
+
end
|
92
|
+
counter = Hash.new(0)
|
93
|
+
|
94
|
+
redis.scan_each do |key|
|
95
|
+
head = key.byteslice(0, config[:key_slice]) \
|
96
|
+
.encode('utf-8',
|
97
|
+
invalid: :replace,
|
98
|
+
undef: :replace,
|
99
|
+
replace: '')
|
100
|
+
head = head.split(config[:split_char])[0, config[:segments]].each { |s| s.tr('.', '_') }.join('.')
|
101
|
+
counter[head] += 1
|
102
|
+
end
|
103
|
+
|
104
|
+
counter.each { |key, count| output "#{config[:scheme]}.db.#{db}.patterns.#{key}", count }
|
105
|
+
end
|
106
|
+
ok
|
107
|
+
end
|
108
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: redis
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.2.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.2.1
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: aws-sdk
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,15 +153,16 @@ dependencies:
|
|
139
153
|
description: Sensu plugins developed by Edgelab
|
140
154
|
email:
|
141
155
|
executables:
|
142
|
-
- check-nomad-jobs.rb
|
143
|
-
- check-swarm-cluster.rb
|
144
|
-
- metrics-aws-rds.rb
|
145
|
-
- metrics-aws-elb.rb
|
146
156
|
- check-nomad-leader.rb
|
157
|
+
- metrics-redis-key-pattern.rb
|
147
158
|
- metrics-aws-asg.rb
|
148
|
-
-
|
149
|
-
- metrics-
|
159
|
+
- metrics-aws-elb.rb
|
160
|
+
- metrics-aws-rds.rb
|
150
161
|
- metrics-mysql-processes.rb
|
162
|
+
- metrics-swarm-cluster.rb
|
163
|
+
- check-nomad-jobs.rb
|
164
|
+
- check-swarm-cluster.rb
|
165
|
+
- check-apt-expired-keys.rb
|
151
166
|
extensions: []
|
152
167
|
extra_rdoc_files: []
|
153
168
|
files:
|
@@ -159,6 +174,7 @@ files:
|
|
159
174
|
- bin/metrics-aws-elb.rb
|
160
175
|
- bin/metrics-aws-rds.rb
|
161
176
|
- bin/metrics-mysql-processes.rb
|
177
|
+
- bin/metrics-redis-key-pattern.rb
|
162
178
|
- bin/metrics-swarm-cluster.rb
|
163
179
|
homepage:
|
164
180
|
licenses: []
|