sensu-plugins-slack 1.1.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9db07df331e402395365319e4772798ce55f79ba
4
- data.tar.gz: 5c44de22dd791ddf483ddcb9b355721cb7cef070
3
+ metadata.gz: a9e17d470810e6c1b420fd9978176d83068be519
4
+ data.tar.gz: 92bc6643bb39dd91419fd92a532b3a51637c9a34
5
5
  SHA512:
6
- metadata.gz: 74fb4ba744491325b6c151329c95cb727d3bb392044d7c95fd91a745066ba387dd61e84b5c4839bf23d226ca73f2206669e8c95250d25b72d794789391dde230
7
- data.tar.gz: 021347360047ba11bc4e35aa86e8c6f32f897dc7a69377a0b97dc008801bc231735280c691ebdb01df773bd26f6a184529a9fb795d98b29bfa3bd062e3609aac
6
+ metadata.gz: 28f88ff3cf8228d5fada54e72e0c902ed08b7cd38729b247162bbf483f1643e14f8b09aba012b29754e48d4aec1f83e4757e9ced821e8be6a01492af6957c58d
7
+ data.tar.gz: f1bc4b64b7297383b597c6f20bb4bad8e9f8994e42b761bc047e3e4b3b5b01d9eb7577379f6a3b540c055bd556e65713fe05c2633d0a105596940a2f8e6463af
data/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.2.0] - 2017-07-13
9
+ ### Added
10
+ - ruby 2.4 testing in travis (@majormoses)
11
+ - `slack-handler-multichannel.rb`: Add custom_field options to supply additional fields (@justbkuz)
12
+
8
13
  ## [1.1.1] - 2017-06-24
9
14
  ### Fixed
10
15
  - Ran rubocop against `bin/slack-handler.rb` and `bin/slack-handler-multichannel.rb` (@pgporada)
@@ -80,7 +85,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
80
85
  ### Added
81
86
  - initial release
82
87
 
83
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/1.1.1...HEAD
88
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/1.2.0...HEAD
89
+ [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/1.1.1...1.2.0
84
90
  [1.1.1]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/1.1.0...1.1.1.
85
91
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/1.0.0...1.1.0
86
92
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-slack/compare/v0.1.2...1.0.0
data/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  * bin/handler-slack.rb
13
13
  * bin/handler-slack-multichannel.rb
14
14
 
15
- ## Usage
15
+ ## Usage for handler-slack.rb
16
16
  ```
17
17
  {
18
18
  "slack": {
@@ -41,6 +41,39 @@
41
41
  }
42
42
  }
43
43
  ```
44
+ ## Usage for handler-slack-multichannel.rb
45
+ ```
46
+ {
47
+ "slack": {
48
+ "webhook_url": "webhook url",
49
+ "channel": {
50
+ "default": [ "#no-team-alerts" ],
51
+ "compulsory": [ "#all-alerts" ]
52
+ }
53
+ "message_prefix": "optional prefix - can be used for mentions",
54
+ "surround": "optional - can be used for bold(*), italics(_), code(`) and preformatted(```)",
55
+ "bot_name": "optional bot name, defaults to slack defined",
56
+ "link_names": "optional - find and link channel names and usernames",
57
+ "message_template": "optional description erb template file - /some/path/to/template.erb",
58
+ "payload_template": "optional json payload template file (note: overrides most other template options.)",
59
+ "template": "backwards-compatible alias for message_template",
60
+ "proxy_address": "The HTTP proxy address (example: proxy.example.com)",
61
+ "proxy_port": "The HTTP proxy port (if there is a proxy)",
62
+ "proxy_username": "The HTTP proxy username (if there is a proxy)",
63
+ "proxy_password": "The HTTP proxy user password (if there is a proxy)",
64
+ "icon_url": "https://raw.githubusercontent.com/sensu/sensu-logo/master/sensu1_flat%20white%20bg_png.png",
65
+ "icon_emoji": ":snowman:",
66
+ "custom_field": [
67
+ "list",
68
+ "of",
69
+ "optional",
70
+ "check_fields",
71
+ "to_render"
72
+ ]
73
+ }
74
+ }
75
+ ```
76
+
44
77
 
45
78
  ## Installation
46
79
 
@@ -41,6 +41,27 @@
41
41
  # ...,
42
42
  # }
43
43
  # }
44
+ #
45
+ # Custom Field support added:
46
+ #
47
+ # Adding custom_field to handler will add a field to message with that fields content, if that field doesn't exist it will be ignored.
48
+ #
49
+ # "slack" {
50
+ # "channels" [ "#db-team-alerts" ],
51
+ # "custom_field" [
52
+ # "field_name",
53
+ # "field_name_2"
54
+ # ]
55
+ # }
56
+ #
57
+ # On your check.json
58
+ #
59
+ # {
60
+ # "checks": {
61
+ # "check_disk_usage": {
62
+ # "command": " ~/check-disk-usage.rb -w 90 -c 95",
63
+ # "field_name": "https://someurl.somewhere",
64
+ # "field_name_2: "something_you_want_added"
44
65
 
45
66
  require 'sensu-handler'
46
67
  require 'json'
@@ -107,6 +128,10 @@ class Slack < Sensu::Handler
107
128
  return false
108
129
  end
109
130
 
131
+ def custom_field
132
+ get_setting('custom_field')
133
+ end
134
+
110
135
  def compile_channel_list
111
136
  channels = []
112
137
 
@@ -231,12 +256,26 @@ class Slack < Sensu::Handler
231
256
  end
232
257
 
233
258
  def payload(notice, channel)
259
+ client_fields = []
260
+
261
+ unless custom_field.nil?
262
+ custom_field.each do |field|
263
+ is_short = true unless @event['client'].key?(field) && @event['client'][field].length > 50
264
+ field_title = field unless @event['check'][field].nil?
265
+ client_fields << {
266
+ title: field_title,
267
+ value: @event['check'][field],
268
+ short: is_short
269
+ }
270
+ end
271
+ end
234
272
  {
235
273
  icon_url: slack_icon_url ? slack_icon_url : 'https://raw.githubusercontent.com/sensu/sensu-logo/master/sensu1_flat%20white%20bg_png.png',
236
274
  attachments: [{
237
275
  title: "#{@event['client']['address']} - #{translate_status}",
238
276
  text: [slack_message_prefix, notice].compact.join(' '),
239
- color: color
277
+ color: color,
278
+ fields: client_fields
240
279
  }]
241
280
  }.tap do |payload|
242
281
  payload[:channel] = channel
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsSlack
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis