sensu-plugins-rabbitmq-cloudwatch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/metrics-rabbitmq-cloudwatch.rb +109 -0
- data/lib/sensu/plugins/rabbitmq/cloudwatch/counts.rb +41 -0
- data/lib/sensu/plugins/rabbitmq/cloudwatch/queues.rb +120 -0
- data/lib/sensu/plugins/rabbitmq/cloudwatch/version.rb +9 -0
- data/lib/sensu/plugins/rabbitmq/cloudwatch.rb +11 -0
- data/sensu-plugins-rabbitmq-cloudwatch.gemspec +35 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52bd1739223b94c9bb72fc266cec8c5d2d88e6cc
|
4
|
+
data.tar.gz: 75f21f3235a75ded8ffffcab6b3448259d575333
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3217c3c9e626d209471f1e6050671669ad3bef16be1e2c1d823fc7b73d9061f0eaaa51480fa9e73c6c620bf661fee2388519285e7ac566bdb056a35a74d0ab55
|
7
|
+
data.tar.gz: 25c23bdfffe394fe1c2670d9ca7d902d601f4a5940a5ea2338ecb1dc738603b6de213c29c3828a99df8ab2b8549eac947818e2cf0e42065ad2f6a8dbb2ab2a1b
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.gems
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Sensu::Plugins::Rabbitmq::Cloudwatch
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sensu/plugins/rabbitmq/cloudwatch`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sensu-plugins-rabbitmq-cloudwatch'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sensu-plugins-rabbitmq-cloudwatch
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sensu-plugins-rabbitmq-cloudwatch.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sensu/plugins/rabbitmq/cloudwatch"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
lib = File.expand_path('../../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'sensu-plugin/cli'
|
8
|
+
require 'carrot-top'
|
9
|
+
require 'aws-sdk'
|
10
|
+
|
11
|
+
require 'sensu/plugins/rabbitmq/cloudwatch/counts'
|
12
|
+
require 'sensu/plugins/rabbitmq/cloudwatch/queues'
|
13
|
+
|
14
|
+
class MetricsRabbitMQ < Sensu::Plugin::CLI
|
15
|
+
|
16
|
+
option :host,
|
17
|
+
description: 'RabbitMQ management API host',
|
18
|
+
long: '--host HOST',
|
19
|
+
default: 'localhost'
|
20
|
+
|
21
|
+
option :port,
|
22
|
+
description: 'RabbitMQ management API port',
|
23
|
+
long: '--port PORT',
|
24
|
+
proc: proc(&:to_i),
|
25
|
+
default: 15_672
|
26
|
+
|
27
|
+
option :user,
|
28
|
+
description: 'RabbitMQ management API user',
|
29
|
+
long: '--user USER',
|
30
|
+
default: 'guest'
|
31
|
+
|
32
|
+
option :password,
|
33
|
+
description: 'RabbitMQ management API password',
|
34
|
+
long: '--password PASSWORD',
|
35
|
+
default: 'guest'
|
36
|
+
|
37
|
+
option :ssl,
|
38
|
+
description: 'Enable SSL for connection to the API',
|
39
|
+
long: '--ssl',
|
40
|
+
boolean: true,
|
41
|
+
default: false
|
42
|
+
|
43
|
+
option :region,
|
44
|
+
description: 'AWS Region',
|
45
|
+
long: '--region REGION',
|
46
|
+
default: 'us-east-1'
|
47
|
+
|
48
|
+
option :namespace,
|
49
|
+
description: 'Namespace',
|
50
|
+
long: '--namespace NAMESPACE',
|
51
|
+
proc: proc(&:strip),
|
52
|
+
default: 'RabbitMQ'
|
53
|
+
|
54
|
+
option :dimensions,
|
55
|
+
description: 'Dimensions key:value,key:value',
|
56
|
+
long: '--dimensions DIMENSIONS',
|
57
|
+
proc: proc(&:strip),
|
58
|
+
default: ''
|
59
|
+
|
60
|
+
def run
|
61
|
+
STDOUT.sync = true
|
62
|
+
|
63
|
+
metrics = []
|
64
|
+
metrics.push(*counts)
|
65
|
+
metrics.push(*queues)
|
66
|
+
metrics.each do |m|
|
67
|
+
m[:dimensions] ||= []
|
68
|
+
m[:dimensions] = Array(m[:dimensions]) + dimensions
|
69
|
+
end
|
70
|
+
|
71
|
+
metrics.each_slice(20) do |m|
|
72
|
+
cloudwatch.put_metric_data(namespace: config[:namespace], metric_data: m)
|
73
|
+
end
|
74
|
+
|
75
|
+
ok
|
76
|
+
rescue => e
|
77
|
+
STDOUT.puts e.message
|
78
|
+
STDOUT.puts e.backtrace
|
79
|
+
exit(2)
|
80
|
+
end
|
81
|
+
|
82
|
+
def counts
|
83
|
+
Sensu::Plugins::Rabbitmq::Cloudwatch::Counts.call(rabbitmq: rabbitmq)
|
84
|
+
end
|
85
|
+
|
86
|
+
def queues
|
87
|
+
Sensu::Plugins::Rabbitmq::Cloudwatch::Queues.call(rabbitmq: rabbitmq)
|
88
|
+
end
|
89
|
+
|
90
|
+
def dimensions
|
91
|
+
@dimenstions ||= (config[:dimensions] || '').split(',')
|
92
|
+
.map { |v| v.split(':') }
|
93
|
+
.map { |name, value| { name: name, value: value } }
|
94
|
+
end
|
95
|
+
|
96
|
+
def cloudwatch
|
97
|
+
@cloudwatch = Aws::CloudWatch::Client.new(region: config[:region])
|
98
|
+
end
|
99
|
+
|
100
|
+
def rabbitmq
|
101
|
+
@rabbitmq ||= CarrotTop.new(
|
102
|
+
host: config[:host],
|
103
|
+
port: config[:port],
|
104
|
+
user: config[:user],
|
105
|
+
password: config[:password],
|
106
|
+
ssl: config[:ssl]
|
107
|
+
)
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Sensu
|
2
|
+
module Plugins
|
3
|
+
module Rabbitmq
|
4
|
+
module Cloudwatch
|
5
|
+
class Counts
|
6
|
+
def self.call(rabbitmq: nil)
|
7
|
+
return unless rabbitmq
|
8
|
+
|
9
|
+
[
|
10
|
+
{
|
11
|
+
metric_name: 'Connections',
|
12
|
+
value: rabbitmq.connections.size,
|
13
|
+
unit: 'Count'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
metric_name: 'Channels',
|
17
|
+
value: rabbitmq.channels.size,
|
18
|
+
unit: 'Count'
|
19
|
+
},
|
20
|
+
{
|
21
|
+
metric_name: 'Exchanges',
|
22
|
+
value: rabbitmq.exchanges.size,
|
23
|
+
unit: 'Count'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
metric_name: 'Queues',
|
27
|
+
value: rabbitmq.queues.size,
|
28
|
+
unit: 'Count'
|
29
|
+
},
|
30
|
+
{
|
31
|
+
metric_name: 'Users',
|
32
|
+
value: rabbitmq.users.size,
|
33
|
+
unit: 'Count'
|
34
|
+
}
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Sensu
|
2
|
+
module Plugins
|
3
|
+
module Rabbitmq
|
4
|
+
module Cloudwatch
|
5
|
+
class Queues
|
6
|
+
|
7
|
+
def self.call(rabbitmq: nil)
|
8
|
+
rabbitmq.queues.map { |queue| metrics_for(queue) }.flatten
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.metrics_for(queue)
|
12
|
+
dimensions = [{ name: 'queue', value: queue['name'] }]
|
13
|
+
|
14
|
+
[
|
15
|
+
{
|
16
|
+
metric_name: 'QueueMemory',
|
17
|
+
value: queue['memory'],
|
18
|
+
unit: 'Bytes'
|
19
|
+
},
|
20
|
+
{
|
21
|
+
metric_name: 'QueueMessages',
|
22
|
+
value: queue['messages'],
|
23
|
+
unit: 'Count'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
metric_name: 'QueueMessagesRate',
|
27
|
+
value: queue['messages_details']['rate'],
|
28
|
+
unit: 'Count/Second'
|
29
|
+
},
|
30
|
+
{
|
31
|
+
metric_name: 'QueueMessagesReady',
|
32
|
+
value: queue['messages_ready'],
|
33
|
+
unit: 'Count'
|
34
|
+
},
|
35
|
+
{
|
36
|
+
metric_name: 'QueueMessagesReadyRate',
|
37
|
+
value: queue['messages_ready_details']['rate'],
|
38
|
+
unit: 'Count/Second'
|
39
|
+
},
|
40
|
+
{
|
41
|
+
metric_name: 'QueueMessagesUnacknowledged',
|
42
|
+
value: queue['messages_unacknowledged'],
|
43
|
+
unit: 'Count'
|
44
|
+
},
|
45
|
+
{
|
46
|
+
metric_name: 'QueueMessagesUnacknowledgedRate',
|
47
|
+
value: queue['messages_unacknowledged_details']['rate'],
|
48
|
+
unit: 'Count/Second'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
metric_name: 'QueueConsumers',
|
52
|
+
value: queue['consumers'],
|
53
|
+
unit: 'Count'
|
54
|
+
},
|
55
|
+
|
56
|
+
{
|
57
|
+
metric_name: 'QueueMessagesRam',
|
58
|
+
value: queue['messages_ram'],
|
59
|
+
unit: 'Bytes'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
metric_name: 'QueueMessagesReadyRam',
|
63
|
+
value: queue['messages_ready_ram'],
|
64
|
+
unit: 'Bytes'
|
65
|
+
},
|
66
|
+
{
|
67
|
+
metric_name: 'QueueUnacknowledgedRam',
|
68
|
+
value: queue['messages_unacknowledged_ram'],
|
69
|
+
unit: 'Bytes'
|
70
|
+
},
|
71
|
+
{
|
72
|
+
metric_name: 'QueueMessagesPersistent',
|
73
|
+
value: queue['messages_persistent'],
|
74
|
+
unit: 'Count'
|
75
|
+
},
|
76
|
+
{
|
77
|
+
metric_name: 'QueueMessageBytes',
|
78
|
+
value: queue['message_bytes'],
|
79
|
+
unit: 'Bytes'
|
80
|
+
},
|
81
|
+
{
|
82
|
+
metric_name: 'QueueMessageBytesReady',
|
83
|
+
value: queue['message_bytes_ready'],
|
84
|
+
unit: 'Bytes'
|
85
|
+
},
|
86
|
+
{
|
87
|
+
metric_name: 'QueueMessageBytesUnacknowledged',
|
88
|
+
value: queue['message_bytes_unacknowledged'],
|
89
|
+
unit: 'Bytes'
|
90
|
+
},
|
91
|
+
{
|
92
|
+
metric_name: 'QueueMessageBytesRam',
|
93
|
+
value: queue['message_bytes_ram'],
|
94
|
+
unit: 'Bytes'
|
95
|
+
},
|
96
|
+
{
|
97
|
+
metric_name: 'QueueMessageBytesPersistent',
|
98
|
+
value: queue['message_bytes_persistent'],
|
99
|
+
unit: 'Bytes'
|
100
|
+
},
|
101
|
+
{
|
102
|
+
metric_name: 'QueueDiskReads',
|
103
|
+
value: queue['disk_reads'],
|
104
|
+
unit: 'Count'
|
105
|
+
},
|
106
|
+
{
|
107
|
+
metric_name: 'QueueDiskWrites',
|
108
|
+
value: queue['disk_writes'],
|
109
|
+
unit: 'Count'
|
110
|
+
}
|
111
|
+
].map do |metric|
|
112
|
+
metric[:dimensions] = dimensions
|
113
|
+
metric
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sensu/plugins/rabbitmq/cloudwatch/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sensu-plugins-rabbitmq-cloudwatch"
|
8
|
+
spec.version = Sensu::Plugins::Rabbitmq::Cloudwatch::VERSION
|
9
|
+
spec.authors = ["Marc Watts"]
|
10
|
+
spec.email = ["marcky.sharky@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Sensu Plugins for RabbitMQ metrics Cloudwatch}
|
13
|
+
spec.description = %q{Send RabbitMQ metrics to Cloudwatch}
|
14
|
+
spec.homepage = "https://github.com/marckysharky/sensu-plugins-rabbitmq-cloudwatch"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "aws-sdk", "~> 2"
|
30
|
+
spec.add_dependency "sensu-plugin", "~> 1"
|
31
|
+
spec.add_dependency "carrot-top", "~> 0"
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-rabbitmq-cloudwatch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marc Watts
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sensu-plugin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: carrot-top
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: Send RabbitMQ metrics to Cloudwatch
|
84
|
+
email:
|
85
|
+
- marcky.sharky@gmail.com
|
86
|
+
executables:
|
87
|
+
- metrics-rabbitmq-cloudwatch.rb
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".ruby-gemset"
|
93
|
+
- ".ruby-version"
|
94
|
+
- Gemfile
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- exe/metrics-rabbitmq-cloudwatch.rb
|
100
|
+
- lib/sensu/plugins/rabbitmq/cloudwatch.rb
|
101
|
+
- lib/sensu/plugins/rabbitmq/cloudwatch/counts.rb
|
102
|
+
- lib/sensu/plugins/rabbitmq/cloudwatch/queues.rb
|
103
|
+
- lib/sensu/plugins/rabbitmq/cloudwatch/version.rb
|
104
|
+
- sensu-plugins-rabbitmq-cloudwatch.gemspec
|
105
|
+
homepage: https://github.com/marckysharky/sensu-plugins-rabbitmq-cloudwatch
|
106
|
+
licenses: []
|
107
|
+
metadata:
|
108
|
+
allowed_push_host: https://rubygems.org
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.5.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Sensu Plugins for RabbitMQ metrics Cloudwatch
|
129
|
+
test_files: []
|