sensu-plugins-hipchat 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Njk0YWY0OWY3M2ZlMTMyMGY1NWM0ZjQ5MmJkM2I5ZGNmNjhiMTZhYQ==
5
- data.tar.gz: !binary |-
6
- YjNiYTZkYTczODAyNzg0MDcyYWE2YjI5ZTQ3NTU4NTc3ZGY0MDQwNw==
2
+ SHA1:
3
+ metadata.gz: 2f5886dabf46c789b374f3960feb35332a02fbd9
4
+ data.tar.gz: d93370b670f9b9f2cbaa89c1592ab525b1fcc6cf
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NzAxNjU5M2ZkZjQzOGI0ZjA0ZmQyNjg4YmZiODYzNmRmM2VhMGY1YTZhMzdm
10
- YWRkNTFhZDkxMWIwOGIxMGQzYTA0MWE1N2RhODU1NTgzMmI2M2Q4MGE3NTAy
11
- YjhlNmY2YzcyNDdmNGI0MTgxMDQyNDQwNjM1ZjlkYzU3MjE5MjU=
12
- data.tar.gz: !binary |-
13
- MTQ4ZmIyNDBiYmYxY2Q2NGIzMWMyMDM0OTQxZDY3ZDQ0ZTc1ZWQxMmNiNGIy
14
- MzZhNTU5YWRlOGUyZTZlYzMyY2NiZTIxMjYwMzY2NjU0OGU1MmEwNDdkYjc5
15
- OTIxMWEwM2I4MDE3YjM2NjZlZjYzZjFiZTM3ZGY0MjBhYjFjMjA=
6
+ metadata.gz: 7ada751ceacd8abd91c7ca33e18bb2ee3beb6b66c9922d56f4a81100c6a64e02493f45b99dbbea7c4c9c3e255bbc60f556c9576b9102dccde3ee70ba05729d87
7
+ data.tar.gz: 26e038c719f36065dcf5e0164ac65304df202cf9ca7494e521303a9787aec6a6cf884ce7ef1f218724773ab44e4a6758b29e8d0bd5f94491e1ed7b735a41419b
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [1.1.0] - 2017-07-12
8
+ ### Added
9
+ - Ruby 2.4.1 testing
10
+
11
+ ### Breaking Changes
12
+ - Dropped Ruby 1.9.3 support
13
+
14
+ ### Changed
15
+ - added option to configure message format in ERB template
16
+ - added option to configure message format as either `html`(default) or `text`
7
17
 
8
18
  ## [0.0.4] - 2016-08-10
9
19
  ### Changed
@@ -27,7 +37,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
27
37
  ### Added
28
38
  - initial release
29
39
 
30
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/0.0.4...HEAD
40
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/1.0.0...HEAD
41
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/0.0.4...1.0.0
31
42
  [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/0.0.3...0.0.4
32
43
  [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/0.0.2...0.0.3
33
44
  [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-hipchat/compare/0.0.1...0.0.2
data/README.md CHANGED
@@ -19,7 +19,9 @@
19
19
  "apikey": "1234abcdefg1234abcdefg",
20
20
  "apiversion": "v1",
21
21
  "room": "Ops",
22
- "from": "Sensu"
22
+ "from": "Sensu",
23
+ "message_template": "optional message template erb file path - /some/path/to/template.erb",
24
+ "message_format": "html"
23
25
  }
24
26
  }
25
27
  ```
@@ -28,3 +30,19 @@
28
30
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
29
31
 
30
32
  ## Notes
33
+
34
+ ### message_template example
35
+
36
+ ```
37
+ <%=
38
+ [
39
+ @event["action"].eql?("resolve") ? "RESOLVED" : "ALERT",
40
+ " - [#{event_name}]<br>",
41
+ "command: #{@event['check']['command']}<br>",
42
+ "occurrences: #{@event['occurrences']}<br>",
43
+ @event["check"]["notification"] || @event["check"]["output"],
44
+ "<br>",
45
+ playbook,
46
+ ].join
47
+ %>
48
+ ```
@@ -25,6 +25,7 @@
25
25
  require 'sensu-handler'
26
26
  require 'hipchat'
27
27
  require 'timeout'
28
+ require 'erubis'
28
29
 
29
30
  class HipChatNotif < Sensu::Handler
30
31
  option :json_config,
@@ -46,30 +47,48 @@ class HipChatNotif < Sensu::Handler
46
47
  hipchatmsg = HipChat::Client.new(settings[json_config]['apikey'], api_version: apiversion, http_proxy: proxy_url, server_url: server_url)
47
48
  room = @event['client']['hipchat_room'] || @event['check']['hipchat_room'] || settings[json_config]['room']
48
49
  from = settings[json_config]['from'] || 'Sensu'
49
-
50
- message = @event['check']['notification'] || @event['check']['output']
50
+ message_template = settings[json_config]['message_template']
51
+ message_format = settings[json_config]['message_format'] || 'html'
51
52
 
52
53
  # If the playbook attribute exists and is a URL, "[<a href='url'>playbook</a>]" will be output.
53
54
  # To control the link name, set the playbook value to the HTML output you would like.
55
+ playbook = ''
54
56
  if @event['check']['playbook']
55
57
  begin
56
58
  uri = URI.parse(@event['check']['playbook'])
57
- message << if %w( http https ).include?(uri.scheme)
58
- " [<a href='#{@event['check']['playbook']}'>Playbook</a>]"
59
- else
60
- " Playbook: #{@event['check']['playbook']}"
61
- end
59
+ playbook << if %w( http https ).include?(uri.scheme)
60
+ " [<a href='#{@event['check']['playbook']}'>Playbook</a>]"
61
+ else
62
+ " Playbook: #{@event['check']['playbook']}"
63
+ end
62
64
  rescue
63
- message << " Playbook: #{@event['check']['playbook']}"
65
+ playbook << " Playbook: #{@event['check']['playbook']}"
64
66
  end
65
67
  end
66
68
 
69
+ if message_template && File.readable?(message_template)
70
+ template = File.read(message_template)
71
+ else
72
+ template = '''<%=
73
+ [
74
+ @event["action"].eql?("resolve") ? "RESOLVED" : "ALERT",
75
+ " - [#{event_name}] - ",
76
+ @event["check"]["notification"] || @event["check"]["output"],
77
+ playbook,
78
+ "."
79
+ ].join
80
+ %>
81
+ '''
82
+ end
83
+ eruby = Erubis::Eruby.new(template)
84
+ message = eruby.result(binding)
85
+
67
86
  begin
68
87
  timeout(3) do
69
88
  if @event['action'].eql?('resolve')
70
- hipchatmsg[room].send(from, "RESOLVED - [#{event_name}] - #{message}.", color: 'green')
89
+ hipchatmsg[room].send(from, message, color: 'green', message_format: message_format)
71
90
  else
72
- hipchatmsg[room].send(from, "ALERT - [#{event_name}] - #{message}.", color: @event['check']['status'] == 1 ? 'yellow' : 'red', notify: true)
91
+ hipchatmsg[room].send(from, message, color: @event['check']['status'] == 1 ? 'yellow' : 'red', notify: true, message_format: message_format)
73
92
  end
74
93
  end
75
94
  rescue Timeout::Error
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsHipchat
2
2
  module Version
3
- MAJOR = 0
3
+ MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 4
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.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: 2016-08-11 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: sensu-plugin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
@@ -38,134 +38,148 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: erubis
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.7.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ~>
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
61
  version: '1.7'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ~>
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.7'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: codeclimate-test-reporter
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0.4'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.4'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: github-markup
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ~>
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
89
  version: '1.3'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ~>
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '1.3'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ~>
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0.10'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ~>
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.10'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ~>
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
117
  version: '10.5'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ~>
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '10.5'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: redcarpet
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ~>
129
+ - - "~>"
116
130
  - !ruby/object:Gem::Version
117
131
  version: '3.2'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ~>
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '3.2'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rubocop
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - ~>
143
+ - - "~>"
130
144
  - !ruby/object:Gem::Version
131
145
  version: 0.40.0
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - ~>
150
+ - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: 0.40.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rspec
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - ~>
157
+ - - "~>"
144
158
  - !ruby/object:Gem::Version
145
159
  version: '3.4'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - ~>
164
+ - - "~>"
151
165
  - !ruby/object:Gem::Version
152
166
  version: '3.4'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: yard
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - ~>
171
+ - - "~>"
158
172
  - !ruby/object:Gem::Version
159
173
  version: '0.8'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - ~>
178
+ - - "~>"
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0.8'
167
181
  description: Sensu plugins for hipchat
168
- email: <sensu-users@googlegroups.com>
182
+ email: "<sensu-users@googlegroups.com>"
169
183
  executables:
170
184
  - handler-hipchat.rb
171
185
  extensions: []
@@ -193,12 +207,12 @@ require_paths:
193
207
  - lib
194
208
  required_ruby_version: !ruby/object:Gem::Requirement
195
209
  requirements:
196
- - - ! '>='
210
+ - - ">="
197
211
  - !ruby/object:Gem::Version
198
212
  version: 1.9.3
199
213
  required_rubygems_version: !ruby/object:Gem::Requirement
200
214
  requirements:
201
- - - ! '>='
215
+ - - ">="
202
216
  - !ruby/object:Gem::Version
203
217
  version: '0'
204
218
  requirements: []