sensu-plugins-flowdock 0.0.2 → 0.1.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: 31b4a10e68af75de14a6df52fe16ef65febe1f09
4
- data.tar.gz: 0d11f1b2ba388c0f5184fba8ec607f52a98fa2a0
3
+ metadata.gz: 4637d3d518f5b4a7279320fe24401333af4460b7
4
+ data.tar.gz: b2519c91eec3e65e64d2fa992a36062c3f4bc6a9
5
5
  SHA512:
6
- metadata.gz: b9345511fa814af76debf9ce1f44e6343155b0a56b1487a648d4f754f30d152e928a25bbae402c57da48675828f1a60d79368669d1ef957898b02ce01e119d3b
7
- data.tar.gz: c80b01b1e07603fcb1cec09e762e1af86aebbd26c5db3402e854f0eefd13d510397d61a7466c53721f94125bafeb848efd8b9b196b6aa3e4ad7c85a59beeea80
6
+ metadata.gz: 3491b875eddcb93630a5f1166c6f145d0e4a77fe5daa2f26f98f78f809251113b1fa5f88790b03c8aecc9706f5a9f92fbbb799e337b1d83ee1d1779a9f7cf67c
7
+ data.tar.gz: 41fd5af972c9c3a1adc065eefa737465c56da3b6c38d631ef421c7d27a60160f5991cec5ba8022c95a2bb629038ce0017586b85d5864a9a2e5b1fddf4372e31d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## Unreleased][unreleased]
7
7
 
8
+ ## [0.1.0] - 2015-10-14
9
+ ### Added
10
+ - Updated README
11
+ - Param -j JsonConfig : To be able to choose config name
12
+ - Change "data" format : To add client name and check name
13
+ - Function build_tag_list : To allow you to change tag by updating flowdock.json into sensu
14
+ - Push type inbox
15
+
8
16
  ## [0.0.2] - 2015-07-14
9
17
  ### Changed
10
18
  - updated sensu-plugin gem to 1.2.0
@@ -13,4 +21,3 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
13
21
 
14
22
  ### Added
15
23
  - initial release
16
-
data/README.md CHANGED
@@ -18,13 +18,32 @@
18
18
  ```
19
19
  {
20
20
  "flowdock": {
21
- "auth_token": "FLOWDOCK_API_TOKEN"
21
+ "auth_token": "FLOWDOCK_API_TOKEN",
22
+ "tags" : "sensu alerting",
23
+ "push_type": "inbox|chat",
24
+ "mail_from": "alerting@sensu.com",
25
+ "name_from": "Sensu",
26
+ "subscriptions": {
27
+ "default": {
28
+ "tags": "default"
29
+ }
30
+ }
22
31
  }
23
32
  }
33
+
34
+ Params are optionals, only auth_token is required.
35
+
36
+ * auth_token : Flowdock token API
37
+ * tag : Fowdock tags separate by " "
38
+ * push_type : Push into inbox or chat (default chat)
39
+ * mail_from : email from for inbox
40
+ * name_from : Name of flowdock/email user
41
+ * subscriptions : Allow to add more tags according to subscriber
42
+
24
43
  ```
25
44
 
26
45
  ## Installation
27
46
 
28
- [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
47
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
29
48
 
30
49
  ## Notes
@@ -16,15 +16,71 @@
16
16
  # Released under the same terms as Sensu (the MIT license); see LICENSE
17
17
  # for details
18
18
 
19
- require 'rubygems' if RUBY_VERSION < '1.9.0'
20
19
  require 'sensu-handler'
21
20
  require 'flowdock'
22
21
 
23
22
  class FlowdockNotifier < Sensu::Handler
23
+ option :json_config,
24
+ description: 'Config Name',
25
+ short: '-j JsonConfig',
26
+ long: '--json_config JsonConfig',
27
+ required: false
28
+
29
+ def build_tags_list
30
+ json_config = config[:json_config] || 'flowdock'
31
+ default_tags = settings[json_config]['tags'] || 'sensu'
32
+ tags = default_tags.split(' ')
33
+ if settings[json_config].key?('subscriptions')
34
+ @event['check']['subscribers'].each do |sub|
35
+ if settings[json_config]['subscriptions'].key?(sub)
36
+ tags.concat settings[json_config]['subscriptions'][sub]['tags'].split(' ')
37
+ end
38
+ end
39
+ end
40
+ tags
41
+ end
42
+
43
+ def action_to_string
44
+ @event['action'].eql?('resolve') ? 'RESOLVED' : 'ALERT'
45
+ end
46
+
47
+ def short_name
48
+ @event['client']['name'] + '/' + @event['check']['name']
49
+ end
50
+
51
+ def status_to_string
52
+ case @event['check']['status']
53
+ when 0
54
+ 'OK'
55
+ when 1
56
+ 'WARNING'
57
+ when 2
58
+ 'CRITICAL'
59
+ else
60
+ 'UNKNOWN'
61
+ end
62
+ end
63
+
24
64
  def handle
25
- token = settings['flowdock']['auth_token']
26
- data = @event['check']['output']
27
- flow = Flowdock::Flow.new(api_token: token, external_user_name: 'Sensu')
28
- flow.push_to_chat(content: data, tags: %w(sensu test))
65
+ json_config = config[:json_config] || 'flowdock'
66
+ token = settings[json_config]['auth_token']
67
+ data = "Host: #{@event['client']['name']} Check: #{@event['check']['name']} - #{@event['check']['output']}"
68
+ tags = build_tags_list
69
+ name_from = settings[json_config]['name_from'] || 'Sensu'
70
+
71
+ push_type = settings[json_config]['push_type'] || 'chat'
72
+ if push_type.eql? 'chat'
73
+ flow = Flowdock::Flow.new(api_token: token, external_user_name: name_from)
74
+ flow.push_to_chat(content: data, tags: tags)
75
+ elsif push_type.eql? 'inbox'
76
+ mail_from = settings[json_config]['mail_from'] || 'alerting@sensu.com'
77
+ if @event['check']['notification'].nil?
78
+ subject_from = "#{action_to_string} - #{short_name}: #{status_to_string}"
79
+ else
80
+ subject_from = "#{action_to_string} - #{short_name}: #{@event['check']['notification']}"
81
+ end
82
+ flow = Flowdock::Flow.new(api_token: token, source: name_from, from: { name: name_from, address: mail_from })
83
+ flow.push_to_team_inbox(subject: subject_from, content: data, tags: tags)
84
+ end
29
85
  end
30
86
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsFlowdock
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- PATCH = 2
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-flowdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -30,8 +30,22 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-07-14 00:00:00.000000000 Z
33
+ date: 2015-10-14 00:00:00.000000000 Z
34
34
  dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: flowdock
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 0.7.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 0.7.0
35
49
  - !ruby/object:Gem::Dependency
36
50
  name: sensu-plugin
37
51
  requirement: !ruby/object:Gem::Requirement
@@ -47,61 +61,61 @@ dependencies:
47
61
  - !ruby/object:Gem::Version
48
62
  version: 1.2.0
49
63
  - !ruby/object:Gem::Dependency
50
- name: codeclimate-test-reporter
64
+ name: bundler
51
65
  requirement: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '0.4'
69
+ version: '1.7'
56
70
  type: :development
57
71
  prerelease: false
58
72
  version_requirements: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - "~>"
61
75
  - !ruby/object:Gem::Version
62
- version: '0.4'
76
+ version: '1.7'
63
77
  - !ruby/object:Gem::Dependency
64
- name: rubocop
78
+ name: codeclimate-test-reporter
65
79
  requirement: !ruby/object:Gem::Requirement
66
80
  requirements:
67
- - - '='
81
+ - - "~>"
68
82
  - !ruby/object:Gem::Version
69
- version: '0.30'
83
+ version: '0.4'
70
84
  type: :development
71
85
  prerelease: false
72
86
  version_requirements: !ruby/object:Gem::Requirement
73
87
  requirements:
74
- - - '='
88
+ - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: '0.30'
90
+ version: '0.4'
77
91
  - !ruby/object:Gem::Dependency
78
- name: rspec
92
+ name: github-markup
79
93
  requirement: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: '3.1'
97
+ version: '1.3'
84
98
  type: :development
85
99
  prerelease: false
86
100
  version_requirements: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - "~>"
89
103
  - !ruby/object:Gem::Version
90
- version: '3.1'
104
+ version: '1.3'
91
105
  - !ruby/object:Gem::Dependency
92
- name: bundler
106
+ name: pry
93
107
  requirement: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - "~>"
96
110
  - !ruby/object:Gem::Version
97
- version: '1.7'
111
+ version: '0.10'
98
112
  type: :development
99
113
  prerelease: false
100
114
  version_requirements: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - "~>"
103
117
  - !ruby/object:Gem::Version
104
- version: '1.7'
118
+ version: '0.10'
105
119
  - !ruby/object:Gem::Dependency
106
120
  name: rake
107
121
  requirement: !ruby/object:Gem::Requirement
@@ -117,61 +131,61 @@ dependencies:
117
131
  - !ruby/object:Gem::Version
118
132
  version: '10.0'
119
133
  - !ruby/object:Gem::Dependency
120
- name: github-markup
134
+ name: redcarpet
121
135
  requirement: !ruby/object:Gem::Requirement
122
136
  requirements:
123
137
  - - "~>"
124
138
  - !ruby/object:Gem::Version
125
- version: '1.3'
139
+ version: '3.2'
126
140
  type: :development
127
141
  prerelease: false
128
142
  version_requirements: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - "~>"
131
145
  - !ruby/object:Gem::Version
132
- version: '1.3'
146
+ version: '3.2'
133
147
  - !ruby/object:Gem::Dependency
134
- name: redcarpet
148
+ name: rspec
135
149
  requirement: !ruby/object:Gem::Requirement
136
150
  requirements:
137
151
  - - "~>"
138
152
  - !ruby/object:Gem::Version
139
- version: '3.2'
153
+ version: '3.1'
140
154
  type: :development
141
155
  prerelease: false
142
156
  version_requirements: !ruby/object:Gem::Requirement
143
157
  requirements:
144
158
  - - "~>"
145
159
  - !ruby/object:Gem::Version
146
- version: '3.2'
160
+ version: '3.1'
147
161
  - !ruby/object:Gem::Dependency
148
- name: yard
162
+ name: rubocop
149
163
  requirement: !ruby/object:Gem::Requirement
150
164
  requirements:
151
- - - "~>"
165
+ - - '='
152
166
  - !ruby/object:Gem::Version
153
- version: '0.8'
167
+ version: 0.32.1
154
168
  type: :development
155
169
  prerelease: false
156
170
  version_requirements: !ruby/object:Gem::Requirement
157
171
  requirements:
158
- - - "~>"
172
+ - - '='
159
173
  - !ruby/object:Gem::Version
160
- version: '0.8'
174
+ version: 0.32.1
161
175
  - !ruby/object:Gem::Dependency
162
- name: pry
176
+ name: yard
163
177
  requirement: !ruby/object:Gem::Requirement
164
178
  requirements:
165
179
  - - "~>"
166
180
  - !ruby/object:Gem::Version
167
- version: '0.10'
181
+ version: '0.8'
168
182
  type: :development
169
183
  prerelease: false
170
184
  version_requirements: !ruby/object:Gem::Requirement
171
185
  requirements:
172
186
  - - "~>"
173
187
  - !ruby/object:Gem::Version
174
- version: '0.10'
188
+ version: '0.8'
175
189
  description: Sensu flowdock plugins
176
190
  email: "<sensu-users@googlegroups.com>"
177
191
  executables:
@@ -211,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
225
  version: '0'
212
226
  requirements: []
213
227
  rubyforge_project:
214
- rubygems_version: 2.4.6
228
+ rubygems_version: 2.4.8
215
229
  signing_key:
216
230
  specification_version: 4
217
231
  summary: Sensu plugins for flowdock
metadata.gz.sig CHANGED
Binary file