sensu-plugins-trello 0.2.1
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/.rubocop.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +76 -0
- data/Rakefile +11 -0
- data/bin/check-trello-incidents.rb +112 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/check_trello_incidents.config.example.json +16 -0
- data/lib/sensu/plugins/trello.rb +9 -0
- data/lib/sensu/plugins/trello/version.rb +7 -0
- data/sensu-plugins-trello.gemspec +29 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 042e69d22c3745b778581a2c9dd2765ae07f7e5e94c03596816271f2b83dccc4
|
4
|
+
data.tar.gz: b96d1937c8eebe2fea1d23b357d7a5c60c77d1dc37e6d3a6a26166649fb48ef6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5417dfe831660182a8d6b58d63a1a6564b4be28290fbdf0ac9c3ad10dee0e9aa61f41391920b725802999b024e381cfc11034e9a6d509449f2c375c78005789
|
7
|
+
data.tar.gz: b948e6cd0a7bf162d31e4529e7f59edff45c311ced4c9e7fdd5ee976166b9fe72be420daadbee126bcc3b24611a2215dd4fb30056cc697efa3776f9f0d632d08
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2018 about:source GmbH
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Sensu check for new incidents in Trello
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/aboutsource/sensu-plugins-trello.svg?branch=master)](https://travis-ci.org/aboutsource/sensu-plugins-trello)
|
4
|
+
|
5
|
+
Checks for cards in a trello list. If cards are present, the check returns
|
6
|
+
_CRITICAL_, containing name and date of last activity of card. When more than
|
7
|
+
one card is present, all card names and dates are returned with *;* delimiter.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'sensu-plugins-trello'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install sensu-plugins-trello
|
24
|
+
|
25
|
+
## CONFIGURATION
|
26
|
+
Configuration of API key and API token should be done through the sensu
|
27
|
+
settings file located in _/etc/sensu/conf.d/_.
|
28
|
+
|
29
|
+
_api_key_ and _api_token_ can be obtained from
|
30
|
+
[Trello](https://trello.com/app-key). _list_ can be obtained by adding _.json_
|
31
|
+
to a card in the browser in the list that should be monitored and search for
|
32
|
+
_idList_ in the JSON-output. Note that in a production environment, _api_key_
|
33
|
+
and _api_token_ should be specified in the Sensu settings rather than through
|
34
|
+
CLI parameters.
|
35
|
+
|
36
|
+
## USAGE
|
37
|
+
Check if a specific trello list is empty or contains cards
|
38
|
+
|
39
|
+
### Required parameters
|
40
|
+
|
41
|
+
| Parameter | Description |
|
42
|
+
| --------- | ----------------------------------- |
|
43
|
+
| -l LIST | id of the Trello list to be checked |
|
44
|
+
| -k KEY | Trello API key |
|
45
|
+
| -t TOKEN | Trello API token |
|
46
|
+
|
47
|
+
### Optional parameters
|
48
|
+
|
49
|
+
| Parameter | Description |
|
50
|
+
| ------------------ | --------------------------------- |
|
51
|
+
| -h HOST | Trello API host |
|
52
|
+
| -p PORT | Trello API port |
|
53
|
+
| --timeout TIMEOUT | Trello request timeout in seconds |
|
54
|
+
|
55
|
+
### Example:
|
56
|
+
```
|
57
|
+
./bin/check-trello-incidents.rb -k 123456789012 -t 1234567890121234567890 -l 1234567890
|
58
|
+
```
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can
|
63
|
+
also run `bin/console` for an interactive prompt that will allow you to
|
64
|
+
experiment.
|
65
|
+
|
66
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
67
|
+
release a new version, update the version number in `version.rb`, and then run
|
68
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
69
|
+
git commits and tags, and push the `.gem` file to
|
70
|
+
[rubygems.org](https://rubygems.org).
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at
|
75
|
+
https://github.com/aboutsource/sensu-plugins-trello.
|
76
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Check for new incidents in Trello
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Checks for cards in a trello list. If cards are present, the check returns
|
7
|
+
# CRITICAL, containing name and date of last activity of card. When more
|
8
|
+
# than one card is present, all card names and dates are returned with ';'
|
9
|
+
# delimiter.
|
10
|
+
#
|
11
|
+
# CONFIGURATION:
|
12
|
+
# Configuration of API key and API token should be done through the sensu
|
13
|
+
# settings file located in /etc/sensu/conf.d/.
|
14
|
+
#
|
15
|
+
# 'api_key' and 'api_token' can be obtained from Trello
|
16
|
+
# (https://trello.com/app-key). 'list' can be obtained by adding .json
|
17
|
+
# to a card in the browser in the list that should be monitored and search
|
18
|
+
# for 'idList' in the JSON-output. Note that in a production environment,
|
19
|
+
# api_key and api_token must be specified in the sensu settings rather than
|
20
|
+
# through CLI parameters
|
21
|
+
#
|
22
|
+
# OUTPUT:
|
23
|
+
# plain text
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# USAGE:
|
27
|
+
# Check if a specific trello list is empty or contains cards
|
28
|
+
# ./check-trello-incidents.rb -k 123456789012 -t 1234567890121234567890 \
|
29
|
+
# -l 1234567890
|
30
|
+
|
31
|
+
require 'sensu-plugin/check/cli'
|
32
|
+
require 'sensu-plugin/utils'
|
33
|
+
require 'json'
|
34
|
+
require 'yaml'
|
35
|
+
require 'net/http'
|
36
|
+
|
37
|
+
class CheckTrelloIncidents < Sensu::Plugin::Check::CLI
|
38
|
+
include Sensu::Plugin::Utils
|
39
|
+
|
40
|
+
option :host,
|
41
|
+
description: 'Trello host address',
|
42
|
+
short: '-h HOST',
|
43
|
+
long: '--host HOST',
|
44
|
+
default: 'api.trello.com'
|
45
|
+
|
46
|
+
option :port,
|
47
|
+
description: 'Trello port',
|
48
|
+
short: '-p PORT',
|
49
|
+
long: '--port PORT',
|
50
|
+
default: 443
|
51
|
+
|
52
|
+
option :list,
|
53
|
+
description: 'Trello list to check',
|
54
|
+
short: '-l LIST',
|
55
|
+
long: '--list LIST'
|
56
|
+
|
57
|
+
option :api_key,
|
58
|
+
description: 'Trello API key',
|
59
|
+
short: '-k KEY',
|
60
|
+
long: '--api-key KEY'
|
61
|
+
|
62
|
+
option :api_token,
|
63
|
+
description: 'Trello API token',
|
64
|
+
short: '-t TOKEN',
|
65
|
+
long: '--api-token TOKEN'
|
66
|
+
|
67
|
+
option :timeout,
|
68
|
+
description: 'Trello request timeout in seconds',
|
69
|
+
long: '--timeout TIMEOUT',
|
70
|
+
default: 30
|
71
|
+
|
72
|
+
def run
|
73
|
+
host = config[:host]
|
74
|
+
port = config[:port].to_i
|
75
|
+
key = config[:api_key] || settings['trello_incidents']['api']['key']
|
76
|
+
token = config[:api_token] || settings['trello_incidents']['api']['token']
|
77
|
+
list = config[:list]
|
78
|
+
timeout = config[:timeout].to_i
|
79
|
+
|
80
|
+
begin
|
81
|
+
Timeout.timeout(timeout) do
|
82
|
+
check_list(host, port, key, token, list)
|
83
|
+
end
|
84
|
+
rescue Timeout::Error
|
85
|
+
unknown 'Connection timed out'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def check_list(host, port, key, token, list)
|
90
|
+
if list.match(/\A[a-z0-9]*\z/).nil?
|
91
|
+
raise format('Invalid value for list parameter: %<list>s', list: list)
|
92
|
+
end
|
93
|
+
|
94
|
+
path = format('/1/lists/%<list>s/cards/', list: list)
|
95
|
+
|
96
|
+
uri = URI.parse(format('https://%<host>s:%<port>d/%<path>s',
|
97
|
+
host: host, port: port, path: path))
|
98
|
+
params = { key: key, token: token }
|
99
|
+
uri.query = URI.encode_www_form(params)
|
100
|
+
|
101
|
+
res = Net::HTTP.get_response(uri)
|
102
|
+
res.value
|
103
|
+
|
104
|
+
incidents = JSON.parse(res.body)
|
105
|
+
|
106
|
+
if incidents.empty?
|
107
|
+
ok 'No new incidents'
|
108
|
+
else
|
109
|
+
critical incidents.map { |incident| incident['name'] }.join('; ')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'sensu/plugins/trello'
|
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,16 @@
|
|
1
|
+
{
|
2
|
+
"checks": {
|
3
|
+
"trello_incidents": {
|
4
|
+
"command": "check-trello-incidents.rb -l <TRELLO-LIST-ID>",
|
5
|
+
"interval": 120,
|
6
|
+
"ttl": 240,
|
7
|
+
"standalone": true
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"trello_incidents": {
|
11
|
+
"api": {
|
12
|
+
"key": "<TRELLO-API-KEY>",
|
13
|
+
"token": "<TRELLO-API-TOKEN>"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'sensu/plugins/trello/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'sensu-plugins-trello'
|
7
|
+
spec.version = Sensu::Plugins::Trello::VERSION
|
8
|
+
spec.licenses = ['MIT']
|
9
|
+
spec.authors = ['Hauke Altmann', 'Stefan Walluhn']
|
10
|
+
spec.email = ['info@aboutsource.net']
|
11
|
+
|
12
|
+
spec.summary = 'Check if a Trello list contains card(s)'
|
13
|
+
spec.description = 'Used for incident management where a card represents '\
|
14
|
+
'an incident.'
|
15
|
+
spec.homepage = 'https://github.com/aboutsource/sensu-plugins-trello'
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.add_dependency 'sensu-plugin', '~> 2.1'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.54'
|
28
|
+
spec.add_development_dependency 'webmock', '~> 3.3'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-trello
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hauke Altmann
|
8
|
+
- Stefan Walluhn
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-03-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sensu-plugin
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.1'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.11'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.11'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.7'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.7'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.54'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.54'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: webmock
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.3'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.3'
|
98
|
+
description: Used for incident management where a card represents an incident.
|
99
|
+
email:
|
100
|
+
- info@aboutsource.net
|
101
|
+
executables:
|
102
|
+
- check-trello-incidents.rb
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/check-trello-incidents.rb
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- check_trello_incidents.config.example.json
|
116
|
+
- lib/sensu/plugins/trello.rb
|
117
|
+
- lib/sensu/plugins/trello/version.rb
|
118
|
+
- sensu-plugins-trello.gemspec
|
119
|
+
homepage: https://github.com/aboutsource/sensu-plugins-trello
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.7.6
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Check if a Trello list contains card(s)
|
143
|
+
test_files: []
|