sensu-plugins-opsgenie 4.0.0 → 4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/bin/handler-opsgenie.rb +17 -10
- data/lib/sensu-plugins-opsgenie/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd3826a3acb4f4fb2321c7a82774d9e9bb2f0da41b4f0ae7ba3bccb0c6c5946
|
4
|
+
data.tar.gz: a393ec78de3a7c46f97754da70e3a5bb0e11c203a77175e87ce6982835f13819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632312ea4f30eaeb5158fd2d5ba993b3413decf572e22d6afa15c41c0bf8f0d991c610e0239fa42132b8a4039731ebda15779b47dbd6d774968060f0e2e18206
|
7
|
+
data.tar.gz: 3a7806f26770a42e7fe833e3188b97c6560d287ea00037db7cee96a8b1acdad258658e79aa34563b29f3d23d99a98a184171c2b665d81e0165770ff94f9e6c30
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [4.0.1] - 2018-01-06
|
9
|
+
### Fixed
|
10
|
+
- Use Alert v2 API, as the Alert v1 API is deprecated (@Castaglia)
|
11
|
+
|
8
12
|
## [4.0.0] - 2017-12-22
|
9
13
|
### Fixed
|
10
14
|
- Use Heartbeat v2 API, as the Heartbeat v1 API is no longer available (@Castaglia)
|
@@ -74,7 +78,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
74
78
|
- initial release
|
75
79
|
- Fixed json configuration load
|
76
80
|
|
77
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.0.
|
81
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.0.1...HEAD
|
82
|
+
[4.0.1]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.0.0...4.0.1
|
78
83
|
[4.0.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/3.1.0...4.0.0
|
79
84
|
[3.1.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/3.0.0...3.1.0
|
80
85
|
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/2.0.1...3.0.0
|
data/bin/handler-opsgenie.rb
CHANGED
@@ -13,7 +13,7 @@ require 'erb'
|
|
13
13
|
class Opsgenie < Sensu::Handler
|
14
14
|
attr_reader :json_config, :message_template
|
15
15
|
|
16
|
-
OPSGENIE_URL = 'https://api.opsgenie.com/
|
16
|
+
OPSGENIE_URL = 'https://api.opsgenie.com/v2/alerts'.freeze
|
17
17
|
|
18
18
|
option :json_config,
|
19
19
|
description: 'Configuration name',
|
@@ -50,10 +50,16 @@ class Opsgenie < Sensu::Handler
|
|
50
50
|
when 'resolve'
|
51
51
|
close_alert
|
52
52
|
end
|
53
|
-
|
53
|
+
case response.code.to_s
|
54
|
+
when '200', '202'
|
54
55
|
puts 'opsgenie -- ' + @event['action'].capitalize + 'd incident -- ' + event_id
|
56
|
+
when '401'
|
57
|
+
puts 'opsgenie -- failed to ' + @event['action'] + ' incident -- not authorized'
|
58
|
+
when '404'
|
59
|
+
puts 'opsgenie -- failed to ' + @event['action'] + ' incident -- ' + event_id + ' not found'
|
55
60
|
else
|
56
61
|
puts 'opsgenie -- failed to ' + @event['action'] + ' incident -- ' + event_id
|
62
|
+
puts "HTTP #{response.code} #{response.message}: #{response.body}"
|
57
63
|
end
|
58
64
|
end
|
59
65
|
rescue Timeout::Error
|
@@ -77,7 +83,10 @@ class Opsgenie < Sensu::Handler
|
|
77
83
|
end
|
78
84
|
|
79
85
|
def event_id
|
80
|
-
|
86
|
+
# Do not use slashes in the event ID, as this alias becomes part of the URI
|
87
|
+
# in the RESTful interactions with OpsGenie; use characters which can be
|
88
|
+
# easily embedded into a URI.
|
89
|
+
@event['client']['name'] + ':' + @event['check']['name']
|
81
90
|
end
|
82
91
|
|
83
92
|
def event_status
|
@@ -102,7 +111,7 @@ class Opsgenie < Sensu::Handler
|
|
102
111
|
message: message,
|
103
112
|
description: json_config['description'],
|
104
113
|
entity: client_name,
|
105
|
-
tags: tags
|
114
|
+
tags: tags,
|
106
115
|
recipients: json_config['recipients'],
|
107
116
|
teams: json_config['teams'])
|
108
117
|
end
|
@@ -119,19 +128,17 @@ class Opsgenie < Sensu::Handler
|
|
119
128
|
end
|
120
129
|
|
121
130
|
def post_to_opsgenie(action = :create, params = {})
|
122
|
-
params['customerKey'] = json_config['customerKey']
|
123
|
-
|
124
131
|
# override source if specified, default is ip
|
125
132
|
params['source'] = json_config['source'] if json_config['source']
|
126
133
|
|
127
|
-
|
134
|
+
encoded_alias = URI.escape(params[:alias])
|
135
|
+
uripath = (action == :create) ? '' : "#{encoded_alias}/close?identifierType=alias"
|
128
136
|
uri = URI.parse("#{OPSGENIE_URL}/#{uripath}")
|
129
137
|
http = Net::HTTP.new(uri.host, uri.port)
|
130
138
|
http.use_ssl = true
|
131
139
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
132
|
-
request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
|
140
|
+
request = Net::HTTP::Post.new(uri.request_uri, 'Authorization' => "GenieKey #{json_config['customerKey']}", 'Content-Type' => 'application/json')
|
133
141
|
request.body = params.to_json
|
134
|
-
|
135
|
-
JSON.parse(response.body)
|
142
|
+
http.request(request)
|
136
143
|
end
|
137
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-opsgenie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
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:
|
11
|
+
date: 2018-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
version: '0'
|
268
268
|
requirements: []
|
269
269
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.7.
|
270
|
+
rubygems_version: 2.7.4
|
271
271
|
signing_key:
|
272
272
|
specification_version: 4
|
273
273
|
summary: Sensu plugins for working with opsgenie
|