sensu-plugins-datadog 0.0.1.alpha.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 +0 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +18 -0
- data/.rubocop.yml +24 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +7 -0
- data/CONTRIBUTING.md +153 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +24 -0
- data/Rakefile +40 -0
- data/Vagrantfile +32 -0
- data/bin/datadog-metrics.rb +68 -0
- data/bin/datadog-notification.rb +110 -0
- data/certs/sensu-plugins.pem +21 -0
- data/lib/sensu-plugins-datadog.rb +7 -0
- data/sensu-plugins-datadog.gemspec +41 -0
- metadata +209 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d1276dc29106a2df5702be29a324d7590e8fe27
|
4
|
+
data.tar.gz: d5fa57237f05d5080c9fccc9d1e46561a7edc5dd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df21f082b73b5ce40a112d05aa1e96c1ce3a661815d419c24db00048ea98e40e4b0474a6cfbefc0e412ee41ccaf6e842d6fd7af6133d2ecabaf26237b9c78b70
|
7
|
+
data.tar.gz: f3a13cc1f6987c3dab46a0cf7fee336dfd4b6cce78d95dcddac5a5fddba98d0c6b81b8af2809bb252541e3ff6ede69dde6019bfb66dbb33e4f87b8f880248439
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
MethodLength:
|
3
|
+
Max: 200
|
4
|
+
|
5
|
+
LineLength:
|
6
|
+
Max: 160
|
7
|
+
|
8
|
+
FileName:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
PerceivedComplexity:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
CyclomaticComplexity:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
ClassLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
IfUnlessModifier:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
RegexpLiteral:
|
24
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache:
|
3
|
+
- bundler
|
4
|
+
install:
|
5
|
+
- bundle install
|
6
|
+
rvm:
|
7
|
+
- 1.9.3
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
notifications:
|
11
|
+
email:
|
12
|
+
recipients:
|
13
|
+
- mattjones@yieldbot.com
|
14
|
+
on_success: change
|
15
|
+
on_failure: always
|
16
|
+
|
17
|
+
script:
|
18
|
+
- 'bundle exec rake default'
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
|
2
|
+
If you have a new plugin or handler, send a pull request! Don't be afraid on pushing your PR with non-ruby code. Just let someone from [team](https://github.com/sensu?tab=members) know. Maybe we can help you to rewrite your check to Ruby or even invent something completely new to test your work. Just don't hesitate to contact us.
|
3
|
+
|
4
|
+
## Naming Conventions
|
5
|
+
|
6
|
+
Please format the names of scripts using dashes to separate words and with an
|
7
|
+
extension (`.rb`, `.sh`, etc), and make sure they are `chmod +x`'d.
|
8
|
+
Extensions are unfortunately necessary for Sensu to be able to directly
|
9
|
+
exec plugins and handlers on Windows.
|
10
|
+
|
11
|
+
## Coding Style
|
12
|
+
|
13
|
+
When developing your plugins please use the [sensu plugin class](https://github.com/sensu/sensu-plugin). This will ensure that all plugins have an identical run structure.
|
14
|
+
|
15
|
+
When using options please use the following structure. At the very least your option needs to include a description to assist the user with configuration and deployment.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
option :port,
|
19
|
+
short: '-p PORT',
|
20
|
+
long: '--port PORT',
|
21
|
+
description: 'Port',
|
22
|
+
default: '1234'
|
23
|
+
```
|
24
|
+
|
25
|
+
Each plugin, handler, mutator, extension should use the following standard header
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
#! /usr/bin/env ruby
|
29
|
+
#
|
30
|
+
# <script name>
|
31
|
+
#
|
32
|
+
# DESCRIPTION:
|
33
|
+
#
|
34
|
+
# OUTPUT:
|
35
|
+
# plain text, metric data, etc
|
36
|
+
#
|
37
|
+
# PLATFORMS:
|
38
|
+
# Linux, Windows, BSD, Solaris, etc
|
39
|
+
#
|
40
|
+
# DEPENDENCIES:
|
41
|
+
# gem: sensu-plugin
|
42
|
+
# gem: <?>
|
43
|
+
#
|
44
|
+
# USAGE:
|
45
|
+
#
|
46
|
+
# NOTES:
|
47
|
+
#
|
48
|
+
# LICENSE:
|
49
|
+
# <your name> <your email>
|
50
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
51
|
+
# for details.
|
52
|
+
#
|
53
|
+
```
|
54
|
+
|
55
|
+
## Documentation
|
56
|
+
|
57
|
+
All documentation will be handled by [RDoc](https://github.com/rdoc/rdoc) and we are using the default rdoc markup at this time. A brief introduction RDoc markup can be found [here](http://docs.seattlerb.org/rdoc/RDoc/Markup.html). All scripts should have as much documentation coverage as possible, ideally 100%. You can test your coverage by installing RDoc locally and running
|
58
|
+
|
59
|
+
```shell
|
60
|
+
rdoc -C <filename>
|
61
|
+
```
|
62
|
+
|
63
|
+
The output will tell you how much coverage you have without spending the time building the docs.
|
64
|
+
|
65
|
+
Documentation can always be made better, if you would like to contribute to it, have at it and submit a PR.
|
66
|
+
|
67
|
+
## Dependency Managment
|
68
|
+
|
69
|
+
Dependencies (ruby gems, packages, etc) and other requirements should
|
70
|
+
be declared in the header of the plugin/handler file. Try to use the standard library or the same dependencies as other plugins to keep the stack as small as possible. If you have questions about using a specific gem feel free to ask.
|
71
|
+
|
72
|
+
All scripts should contain the following dependency to ensure full compatibility.
|
73
|
+
|
74
|
+
## Vagrant Box
|
75
|
+
|
76
|
+
There is a Vagrantfile in each repo with shell provisioning that will setup the major versions of Ruby and a sensu gemset for each if you wish to use it. To get started install [Vagrant](https://www.vagrantup.com/) then type *vagrant up* in the root directory of the repo. Once it is up type *vagrant ssh* to remote into the box and then *cd /vagrant && bundle install* to set all necessary dependencies.
|
77
|
+
|
78
|
+
The box currently defaults to Ruby 2.1.4 but has 1.9.3 and 2.0.0 installed as well. See the file comments for further details.
|
79
|
+
|
80
|
+
## Testing
|
81
|
+
|
82
|
+
### Linting
|
83
|
+
Only pull requests passing lint/tests will be merged.
|
84
|
+
|
85
|
+
Rubocop is used to lint the style of the ruby plugins. This is done to standardize the style used within these plugins, and ensure high quality code. Most current rules are currently in effect. No linting is done on Ruby code prior to version 2x. See the `.travis.yml` and `Rakefile` in each repository for specific details as the tasks may vary between repo.
|
86
|
+
|
87
|
+
Ruby 1.9.2 and 1.8.7 support has been dropped, the plugins may still function with these versions but no tests will be run against them nor will code, such as hashes, be specifically written or enforced to ensure backwards compatibility.
|
88
|
+
|
89
|
+
You can test rubocop compliance for yourself by installing the gem and running `rubocop` from the command line.
|
90
|
+
Running `rubocop -a` will attempt to autocorrect any issues, saving yourself considerable time in large files.
|
91
|
+
|
92
|
+
If it truly makes sense for your code to violate a rule you can disable that rule with your code by either using
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
# rubocop:disable <rule>, <rule>
|
96
|
+
```
|
97
|
+
|
98
|
+
at the end of the line in violation or
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
rubocop:disable <rule>, <rule>
|
102
|
+
<code block>
|
103
|
+
rubocop:enable <rule>, <rule>
|
104
|
+
```
|
105
|
+
|
106
|
+
If you use either of these methods please mention in the PR as this should be kept to an absolute minimum at times, but can be necessary, especially concerning method length and complexity.
|
107
|
+
|
108
|
+
### Rspec
|
109
|
+
|
110
|
+
Currently we have RSpec3 as a [test framework](https://github.com/sensu/sensu-plugin-spec). Please add coverage for your check. Checks will not be considered production grade and stable until they have complete coverage.
|
111
|
+
|
112
|
+
You can use the included Vagrantfile for easy testing. All necessary versions of Ruby can be installed with their own dedicated gem sets using RVM. Just boot up the machine and drop into /vagrant and execute
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
rake default
|
116
|
+
```
|
117
|
+
|
118
|
+
to run all specs and rubocop tests. RSpec tests are currently run against 2.0, and 2.1. There are currently no plans to support 1.8.x or test against 1.9.2 and 1.9.3.
|
119
|
+
|
120
|
+
This is little bit hard almost impossible for non-ruby checks. Let someone from [team](https://github.com/sensu?tab=members) know and maybe can can help.
|
121
|
+
|
122
|
+
## Issue and Pull Request Submissions
|
123
|
+
|
124
|
+
If you see something wrong or come across a bug please open up an issue. Try to include as much data in the issue as possible. If you feel the issue is critical than tag a core member and we will respond as soon as is feasible.
|
125
|
+
|
126
|
+
When submitting a pull request please follow the guidelines below for the quickest possible merge. These not only make our lives easier, but also keep the repo and commit history as clean as possible.
|
127
|
+
|
128
|
+
* When at all possible do a ```git pull --rebase``` both before you start working on the repo and then before you commit. This will help ensure you have the most up to date codebase, Rubocop rules, and documentation. It will also go along way towards cutting down or eliminating(hopefully) annoying merge commits.
|
129
|
+
*
|
130
|
+
|
131
|
+
If you wish to track the status of your PR or issue, check out our [waffle.io](https://waffle.io/sensu/sensu-community-plugins). This single location will allow contributors to stay on top of interwinding issues more effectively.
|
132
|
+
|
133
|
+
Please do not not abandon your pull request, only you can help us merge it. We will wait for feedback from you on your pull request for up to one month. A lack of feedback in one month may require you to re-open your pull request.
|
134
|
+
|
135
|
+
## Technical Debt
|
136
|
+
|
137
|
+
For those who don't deal with or understand technical debt, it is debt incurred when designing or developing software. All the #FIXME, #HACK, etc littered through a script add up over time, this is your technical debt.
|
138
|
+
|
139
|
+
### Technical Debt Levels
|
140
|
+
|
141
|
+
**YELLOW**
|
142
|
+
|
143
|
+
* simple issues that require basic Ruby and no more than 4 hours to fix
|
144
|
+
|
145
|
+
**ORANGE**
|
146
|
+
|
147
|
+
* these may require 4 - 8 hours but still only a basic or intermediate Ruby skillset
|
148
|
+
|
149
|
+
**RED**
|
150
|
+
|
151
|
+
* may require 8+ hours or some domain specific Ruby skills such as Amazon, or Elastic Search
|
152
|
+
|
153
|
+
In order to quantify it and see what we actually have there is a rake task *calculate_debt*. In order to run it you will need an auth token and write access to the repo.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Matt Jones
|
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,24 @@
|
|
1
|
+
## Sensu-Plugins-Datadog
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-datadog.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-datadog)
|
4
|
+
|
5
|
+
## Functionality
|
6
|
+
```json
|
7
|
+
{
|
8
|
+
"datadog": {
|
9
|
+
"api_key": "12345",
|
10
|
+
"app_key": "54321",
|
11
|
+
"tags": []
|
12
|
+
}
|
13
|
+
}
|
14
|
+
```
|
15
|
+
## Files
|
16
|
+
* bin/datadog-metrics
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
`gem install sensu-plugins-datadog`
|
21
|
+
|
22
|
+
Add *sensu-plugins-datadog* to your Gemfile, manifest, cookbook, etc
|
23
|
+
|
24
|
+
## Notes
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require 'github/markup'
|
5
|
+
require 'redcarpet'
|
6
|
+
require 'yard'
|
7
|
+
require 'yard/rake/yardoc_task'
|
8
|
+
|
9
|
+
desc 'Don\'t run Rubocop for unsupported versions'
|
10
|
+
begin
|
11
|
+
if RUBY_VERSION >= '2.0.0'
|
12
|
+
args = [:spec, :make_bin_executable, :yard, :rubocop]
|
13
|
+
else
|
14
|
+
args = [:spec, :make_bin_executable, :yard]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
YARD::Rake::YardocTask.new do |t|
|
19
|
+
OTHER_PATHS = %w()
|
20
|
+
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
|
21
|
+
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md,CONTRIBUTING.md)
|
22
|
+
end
|
23
|
+
|
24
|
+
Rubocop::RakeTask.new
|
25
|
+
|
26
|
+
RSpec::Core::RakeTask.new(:spec) do |r|
|
27
|
+
r.pattern = FileList['**/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
# desc 'Calculate technical debt'
|
31
|
+
# task :calculate_debt do
|
32
|
+
# `/usr/bin/env ruby scripts/tech_debt.rb`
|
33
|
+
# end
|
34
|
+
|
35
|
+
desc 'Make all plugins executable'
|
36
|
+
task :make_bin_executable do
|
37
|
+
`chmod -R +x bin/*`
|
38
|
+
end
|
39
|
+
|
40
|
+
task default: args
|
data/Vagrantfile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
VAGRANTFILE_API_VERSION = '2'
|
5
|
+
|
6
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
7
|
+
|
8
|
+
config.vm.box = 'chef/centos-6.5'
|
9
|
+
config.vm.box_download_checksum = true
|
10
|
+
config.vm.box_download_checksum_type = 'md5'
|
11
|
+
config.vm.hostname = 'sensu-plugins-dev'
|
12
|
+
|
13
|
+
script = <<EOF
|
14
|
+
sudo yum update -y
|
15
|
+
sudo yum groupinstall -y development
|
16
|
+
sudo yum install -y vim nano
|
17
|
+
sudo yum install -y ImagicMagic ImageMagick-devel mysql-devel # needed for bundle install
|
18
|
+
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
|
19
|
+
curl -L get.rvm.io | bash -s stable
|
20
|
+
source /home/vagrant/.rvm/scripts/rvm
|
21
|
+
rvm reload
|
22
|
+
rvm install 1.9.3
|
23
|
+
rvm install 2.1.4
|
24
|
+
rvm install 2.0.0
|
25
|
+
rvm use 1.9.3@sensu_plugins --create
|
26
|
+
rvm use 2.0.0@sensu_plugins --create
|
27
|
+
rvm use 2.1.4@sensu_plugins --create
|
28
|
+
rvm use 2.1.4@sensu_plugins --default
|
29
|
+
EOF
|
30
|
+
|
31
|
+
config.vm.provision 'shell', inline: script, privileged: false
|
32
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# datadog-metrics
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# metric data
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-handler
|
15
|
+
# gem: dogapi
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
#
|
19
|
+
# NOTES:
|
20
|
+
#
|
21
|
+
# LICENSE:
|
22
|
+
# Copyright 2013 Katherine Daniels (kd@gc.io)
|
23
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
24
|
+
# for details.
|
25
|
+
#
|
26
|
+
|
27
|
+
require 'sensu-handler'
|
28
|
+
require 'dogapi'
|
29
|
+
|
30
|
+
#
|
31
|
+
# Datadog Metrics
|
32
|
+
#
|
33
|
+
class DatadogMetrics < Sensu::Handler
|
34
|
+
# Override filters from Sensu::Handler.
|
35
|
+
# They are not appropriate for metric handlers
|
36
|
+
#
|
37
|
+
def filter
|
38
|
+
end
|
39
|
+
|
40
|
+
# Create a handle and event set
|
41
|
+
#
|
42
|
+
def handle
|
43
|
+
@dog = Dogapi::Client.new(settings['datadog']['api_key'], settings['datadog']['app_key'])
|
44
|
+
|
45
|
+
@event['check']['output'].split("\n").each do |line|
|
46
|
+
name, value, timestamp = line.split(/\s+/)
|
47
|
+
emit_metric(name, value, timestamp)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Push metric point
|
52
|
+
#
|
53
|
+
# @param name [String]
|
54
|
+
# @param value [String]
|
55
|
+
# @param _timestamp [String]
|
56
|
+
def emit_metric(name, value, _timestamp)
|
57
|
+
timeout(3) do
|
58
|
+
@dog.emit_point(name, value, host: @event['client']['name'])
|
59
|
+
end
|
60
|
+
# Raised when any metrics could not be sent
|
61
|
+
#
|
62
|
+
rescue Timeout::Error
|
63
|
+
puts 'datadog -- timed out while sending metrics'
|
64
|
+
rescue => error
|
65
|
+
puts "datadog -- failed to send metrics: #{error.message}"
|
66
|
+
puts " #{error.backtrace.join("\n\t")}"
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# datadog-notification
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# plain text
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-handler
|
15
|
+
# gem: dogapi
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
#
|
19
|
+
# NOTES:
|
20
|
+
#
|
21
|
+
# LICENSE:
|
22
|
+
# Copyright 2015 Sonian, Inc <support@sensuapp.net>
|
23
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
24
|
+
# for details.
|
25
|
+
#
|
26
|
+
|
27
|
+
require 'sensu-handler'
|
28
|
+
require 'dogapi'
|
29
|
+
|
30
|
+
#
|
31
|
+
# Datadog notifications
|
32
|
+
#
|
33
|
+
class DatadogNotif < Sensu::Handler
|
34
|
+
# filter disabled alerts and exit with an 'OK' status if it is
|
35
|
+
# else handle the alert as needed
|
36
|
+
#
|
37
|
+
def handle
|
38
|
+
filter
|
39
|
+
datadog
|
40
|
+
end
|
41
|
+
|
42
|
+
# determine the action to take for the event
|
43
|
+
def acquire_action
|
44
|
+
case @event['action']
|
45
|
+
when 'create'
|
46
|
+
'error'
|
47
|
+
when 'resolve'
|
48
|
+
'success'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return a low priotiry for resolve and warn events, normal for critical and unknown
|
53
|
+
def acquire_priority
|
54
|
+
case @event['status']
|
55
|
+
when '0', '1'
|
56
|
+
'low'
|
57
|
+
when '2', '3'
|
58
|
+
'normal'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# filter disabled alerts and exit with an 'OK' status if it is
|
63
|
+
def filter
|
64
|
+
# #YELLOW
|
65
|
+
if @event['check']['alert'] == false # rubocop:disable GuardClause
|
66
|
+
puts 'alert disabled -- filtered event ' + [@event['client']['name'], @event['check']['name']].join(' : ')
|
67
|
+
exit 0
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# submit the event to datadog
|
72
|
+
def datadog
|
73
|
+
description = @event['notification'] || [@event['client']['name'], @event['check']['name'], @event['check']['output']].join(' ')
|
74
|
+
action = acquire_action
|
75
|
+
priority = acquire_priority
|
76
|
+
tags = []
|
77
|
+
tags.push('sensu')
|
78
|
+
# allow for tags to be set in the configuration, this could be used to indicate environment
|
79
|
+
tags.concat(settings['datadog']['tags']) unless settings['datadog']['tags'].nil? && !settings['datadog']['tags'].kind_of(Array)
|
80
|
+
# add the subscibers for the event to the tags
|
81
|
+
tags.concat(@event['check']['subscribers']) unless @event['check']['subscribers'].nil?
|
82
|
+
begin
|
83
|
+
timeout(3) do
|
84
|
+
dog = Dogapi::Client.new(settings['datadog']['api_key'], settings['datadog']['app_key'])
|
85
|
+
response = dog.emit_event(Dogapi::Event.new(
|
86
|
+
description,
|
87
|
+
msg_title: @event['check']['name'],
|
88
|
+
tags: tags,
|
89
|
+
alert_type: action,
|
90
|
+
priority: priority,
|
91
|
+
source_type_name: 'nagios', # make events appear as nagios alerts so the weekly nagios report can be produced
|
92
|
+
aggregation_key: @event['check']['name']
|
93
|
+
), host: @event['client']['name']
|
94
|
+
)
|
95
|
+
|
96
|
+
begin
|
97
|
+
if response[0] == '202'
|
98
|
+
puts 'Submitted event to Datadog'
|
99
|
+
else
|
100
|
+
puts "Unexpected response from Datadog: HTTP code #{response[0]}"
|
101
|
+
end
|
102
|
+
rescue
|
103
|
+
puts "Could not determine whether sensu event was successfully submitted to Datadog: #{response}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
rescue Timeout::Error
|
107
|
+
puts 'Datadog timed out while attempting to ' + @event['action'] + ' a incident -- ' + incident_key
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
3
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
4
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
5
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
6
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
7
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
8
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
9
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
10
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
11
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
12
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
13
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
14
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
15
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
16
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
17
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
18
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
19
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
20
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
21
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,41 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
if RUBY_VERSION < '2.0.0'
|
6
|
+
require 'sensu-plugins-datadog'
|
7
|
+
else
|
8
|
+
require_relative 'lib/sensu-plugins-datadog'
|
9
|
+
end
|
10
|
+
|
11
|
+
pvt_key = '~/.ssh/gem-private_key.pem'
|
12
|
+
|
13
|
+
Gem::Specification.new do |s|
|
14
|
+
s.name = 'sensu-plugins-datadog'
|
15
|
+
s.version = SensuPluginsDatadog::VERSION
|
16
|
+
s.authors = ['Sonian, Inc. and contributors']
|
17
|
+
s.email = '<sensu-users@googlegroups.com>'
|
18
|
+
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-datadog'
|
19
|
+
s.summary = 'Datadog handlers Sensu'
|
20
|
+
s.description = 'Datadog handlers Sensu'
|
21
|
+
s.license = 'MIT'
|
22
|
+
s.date = Date.today.to_s
|
23
|
+
s.files = `git ls-files -z`.split("\x0")
|
24
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
26
|
+
s.require_paths = ['lib']
|
27
|
+
s.cert_chain = ['certs/sensu-plugins.pem']
|
28
|
+
s.signing_key = File.expand_path(pvt_key) if $PROGRAM_NAME =~ /gem\z/
|
29
|
+
s.platform = Gem::Platform::RUBY
|
30
|
+
|
31
|
+
s.add_runtime_dependency 'datadog', '0.1.0.alpha'
|
32
|
+
s.add_runtime_dependency 'sensu-plugin', '1.1.0'
|
33
|
+
|
34
|
+
s.add_development_dependency 'rubocop', '~> 0.17.0'
|
35
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
36
|
+
s.add_development_dependency 'bundler', '~> 1.7'
|
37
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
38
|
+
s.add_development_dependency 'github-markup'
|
39
|
+
s.add_development_dependency 'redcarpet'
|
40
|
+
s.add_development_dependency 'yard'
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-datadog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sonian, Inc. 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-01-29 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: datadog
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.1.0.alpha
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.1.0.alpha
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: sensu-plugin
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.0
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rubocop
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.17.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.17.0
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rspec
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.1'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.1'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: bundler
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.7'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.7'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rake
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '10.0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '10.0'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: github-markup
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: redcarpet
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: yard
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
description: Datadog handlers Sensu
|
162
|
+
email: <sensu-users@googlegroups.com>
|
163
|
+
executables:
|
164
|
+
- datadog-metrics.rb
|
165
|
+
- datadog-notification.rb
|
166
|
+
extensions: []
|
167
|
+
extra_rdoc_files: []
|
168
|
+
files:
|
169
|
+
- .gitignore
|
170
|
+
- .rubocop.yml
|
171
|
+
- .travis.yml
|
172
|
+
- CHANGELOG.md
|
173
|
+
- CONTRIBUTING.md
|
174
|
+
- Gemfile
|
175
|
+
- LICENSE
|
176
|
+
- README.md
|
177
|
+
- Rakefile
|
178
|
+
- Vagrantfile
|
179
|
+
- bin/datadog-metrics.rb
|
180
|
+
- bin/datadog-notification.rb
|
181
|
+
- certs/sensu-plugins.pem
|
182
|
+
- lib/sensu-plugins-datadog.rb
|
183
|
+
- sensu-plugins-datadog.gemspec
|
184
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-datadog
|
185
|
+
licenses:
|
186
|
+
- MIT
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '>'
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.3.1
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.0.14
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: Datadog handlers Sensu
|
208
|
+
test_files: []
|
209
|
+
has_rdoc:
|
metadata.gz.sig
ADDED