sensu-plugins-sendgrid 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b124e564d136c9fa7874d385c50e03cfcf20ccf5
4
+ data.tar.gz: 22a89a9058fdbd0be0fa42ac2976b574e788b24e
5
+ SHA512:
6
+ metadata.gz: 4bcaf10b2bd3e15de072a7303b76fa09e53e290ffe3446dfca2dd57b42b9c9381c45bd8de5f00bc13929c8486788d1b8079a9b4dfdf8b03d458b8878b10e38fb
7
+ data.tar.gz: e3e3a3ca122ad34d42fc70d2c9615db0278c9119834dde9329d8cec67697b8fb5edc72a1d6389280c977f0fabc08fc896078d27796abd53accb0002c74d8e60c
@@ -0,0 +1,19 @@
1
+ # Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format located [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.0.1] - 2018-02-08
9
+
10
+ ### Breaking Changes
11
+ - bumped dependency of `sensu-plugin` to 2.x you can read about it [here](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29) (@majormoses)
12
+ - dropped ruby 2.0 support (@majormoses)
13
+
14
+ ### Added
15
+ - Initial code upload, original source is unknown
16
+ - updated code to community standards on things like ruby versions, `sensu-plugin`, etc
17
+
18
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sendgrid/compare/0.0.1...HEAD
19
+ [0.0.1]: https://github.com/sensu-plugins/sensu-plugins-sendgrid/compare/95f89238462b916c5dc2758258f06f70bccd0910...0.0.1
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sensu Community Plugins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do 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.
22
+
@@ -0,0 +1,17 @@
1
+ ## Sensu-Plugins-Sendgrid
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-skel.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-skel)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-skel.svg)](http://badge.fury.io/rb/sensu-plugins-skel)
5
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-skel.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-skel)
6
+
7
+ ## Functionality
8
+
9
+ ## Files
10
+
11
+ ## Usage
12
+
13
+ ## Installation
14
+
15
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
16
+
17
+ ## Notes
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Sensu Handler: sendgrid
4
+ #
5
+ # This handler formats alerts as mails and sends them off to a pre-defined recipient.
6
+ #
7
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
8
+ # for details.
9
+
10
+ require 'sensu-handler'
11
+ require 'mail'
12
+ require 'timeout'
13
+
14
+ class Sendgrid < Sensu::Handler
15
+ def short_name
16
+ @event['client']['name'] + '/' + @event['check']['name']
17
+ end
18
+
19
+ def action_to_string
20
+ @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
21
+ end
22
+
23
+ def default_config
24
+ # _ Global Settings
25
+ smtp_address = settings['sendgrid']['smtp_address'] || 'smtp.sendgrid.net'
26
+ smtp_port = settings['sendgrid']['smtp_port'] || '587'
27
+ smtp_domain = settings['sendgrid']['smtp_domain'] || 'localhost.localdomain'
28
+ smtp_user = settings['sendgrid']['smtp_user'] || 'yourusername@domain.com'
29
+ smtp_password = settings['sendgrid']['smtp_password'] || 'yourPassword'
30
+ smtp_auth = settings['sendgrid']['smtp_auth'] || 'plain'
31
+
32
+ defaults = {
33
+ 'mail_from' => settings['sendgrid']['mail_from'] || 'localhost',
34
+ 'mail_to' => settings['sendgrid']['mail_to'] || 'root@localhost'
35
+ }
36
+
37
+ # Merge per-check configs
38
+ defaults.merge!(@event['check']['sendgrid'] || {})
39
+
40
+ {
41
+ mail_to: defaults['mail_to'],
42
+ mail_from: defaults['mail_from'],
43
+ smtp_addr: smtp_address,
44
+ smtp_port: smtp_port,
45
+ smtp_domain: smtp_domain,
46
+ smtp_user: smtp_user,
47
+ smtp_password: smtp_password,
48
+ smtp_auth: smtp_auth
49
+ }
50
+ end
51
+
52
+ def handle
53
+ params = default_config
54
+
55
+ body = <<-BODY.gsub(/^ {14}/, '')
56
+ #{@event['check']['output']}
57
+ Host: #{@event['client']['name']}
58
+ Timestamp: #{Time.at(@event['check']['issued'])}
59
+ Address: #{@event['client']['address']}
60
+ Check Name: #{@event['check']['name']}
61
+ Command: #{@event['check']['command']}
62
+ Status: #{@event['check']['status']}
63
+ Occurrences: #{@event['occurrences']}
64
+ Environment: #{@event['client']['environment']}
65
+ Uchiwa Host Link: https://sensu.aerserv.com/#/client/Sensu-localhost/#{@event['client']['name']}
66
+ AWS Host Link: https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Instances:search=#{@event['client']['name']};sort=instanceType
67
+ Uchiwa Alert Link: https://sensu.aerserv.com/#/client/Sensu-localhost/#{@event['client']['name']}?check=#{@event['check']['name']}
68
+ BODY
69
+ body << "Runbook: #{@event['check']['runbook']}" if @event['check']['runbook']
70
+ subject = "#{action_to_string} - #{short_name}: #{@event['check']['notification']}"
71
+
72
+ Mail.defaults do
73
+ delivery_method :smtp,
74
+ address: params[:smtp_addr],
75
+ port: params[:smtp_port],
76
+ domain: params[:smtp_domain],
77
+ user_name: params[:smtp_user],
78
+ password: params[:smtp_password],
79
+ enable_starttls_auto: true
80
+ end
81
+
82
+ begin
83
+ timeout 10 do
84
+ Mail.deliver do
85
+ to params[:mail_to]
86
+ from params[:mail_from]
87
+ subject subject
88
+ body body
89
+ end
90
+
91
+ puts 'sendgrid -- sent alert for ' + short_name + ' to ' + params[:mail_to]
92
+ end
93
+ rescue Timeout::Error
94
+ puts 'sendgrid -- timed out while attempting to ' + @event['action'] + ' an incident -- ' + short_name
95
+ end
96
+ end
97
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-sendgrid/version'
@@ -0,0 +1,8 @@
1
+ module SensuPluginsSendgrid
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,278 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-sendgrid
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
+ date: 2018-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: github-markup
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: kitchen-docker
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: kitchen-localhost
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mixlib-shellout
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "<"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.3.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '2.2'
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "<"
98
+ - !ruby/object:Gem::Version
99
+ version: 2.3.0
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.10'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.10'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rake
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '12.0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '12.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: redcarpet
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '3.2'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '3.2'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rspec
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '3.4'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '3.4'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: 0.49.0
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: 0.49.0
173
+ - !ruby/object:Gem::Dependency
174
+ name: serverspec
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '2.36'
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 2.36.1
183
+ type: :development
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '2.36'
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 2.36.1
193
+ - !ruby/object:Gem::Dependency
194
+ name: test-kitchen
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '1.6'
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: '1.6'
207
+ - !ruby/object:Gem::Dependency
208
+ name: yard
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: '0.8'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: '0.8'
221
+ - !ruby/object:Gem::Dependency
222
+ name: psych
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "<="
226
+ - !ruby/object:Gem::Version
227
+ version: 3.0.0
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "<="
233
+ - !ruby/object:Gem::Version
234
+ version: 3.0.0
235
+ description: Sensu plugins for Sendgrid
236
+ email: "<sensu-users@googlegroups.com>"
237
+ executables:
238
+ - handler-sendgrid.rb
239
+ extensions: []
240
+ extra_rdoc_files: []
241
+ files:
242
+ - CHANGELOG.md
243
+ - LICENSE
244
+ - README.md
245
+ - bin/handler-sendgrid.rb
246
+ - lib/sensu-plugins-sendgrid.rb
247
+ - lib/sensu-plugins-sendgrid/version.rb
248
+ homepage: https://github.com/sensu-plugins/sensu-plugins-sendgrid
249
+ licenses:
250
+ - MIT
251
+ metadata:
252
+ maintainer: sensu-plugin
253
+ development_status: active
254
+ production_status: unstable - testing recommended
255
+ release_draft: 'false'
256
+ release_prerelease: 'false'
257
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
258
+ in /etc/default/sensu
259
+ rdoc_options: []
260
+ require_paths:
261
+ - lib
262
+ required_ruby_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: 2.0.0
267
+ required_rubygems_version: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ requirements: []
273
+ rubyforge_project:
274
+ rubygems_version: 2.5.2.1
275
+ signing_key:
276
+ specification_version: 4
277
+ summary: Sensu plugins for Sendgrid Email Delivery Service
278
+ test_files: []