sensu-plugins-opsgenie 4.1.2 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +48 -1
- data/bin/handler-opsgenie.rb +27 -3
- data/lib/sensu-plugins-opsgenie/version.rb +2 -2
- 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: 60da9a2150addc0545bb2b0f982c4f803e6fc8444b26499a9ff55a3dc10571a2
|
4
|
+
data.tar.gz: 4af0d744eb11c9e6633c01f2be7f85a7ecccb89b7795f17bdbed220da73a7095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 517c8af283e218ef9bef4bda6034c70866d38509ac5eb996f56f6f817b8001e2c1d849fab103fb53cf3c4e07f93e60d49cab3d08524710aefb1a62b8a41c414d
|
7
|
+
data.tar.gz: 27e42a03d769276d52f77ae245bcfce0da47cf74ee2ecc259d860e182623f9b95509f092a13c1c99cebf82b786232d376a5f4fcc761bd4d2e63c5a4760cb0a55
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [4.2.0] - 2018-02-20
|
9
|
+
### Changed
|
10
|
+
- Providing better alert description field using Sensu check output (@Castaglia)
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- `handler-opsgenie.rb`: Added flag of `--verbose` to enable verbose/debugging output (@Castaglia)
|
14
|
+
|
8
15
|
## [4.1.2] - 2018-02-05
|
9
16
|
### Fixed
|
10
17
|
- Handling of tags for events (@Castaglia)
|
@@ -100,6 +107,7 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
100
107
|
- Fixed json configuration load
|
101
108
|
|
102
109
|
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.2...HEAD
|
110
|
+
[4.2.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.2...4.2.0
|
103
111
|
[4.1.2]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.1...4.1.2
|
104
112
|
[4.1.1]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.0...4.1.1
|
105
113
|
[4.1.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.0.1...4.1.0
|
data/README.md
CHANGED
@@ -81,7 +81,54 @@ To get this to work you need to specify a few different things. For a list of fi
|
|
81
81
|
}
|
82
82
|
```
|
83
83
|
|
84
|
-
##
|
84
|
+
## OpsGenie Alerts
|
85
|
+
|
86
|
+
How does the handler map the various Sensu values into the OpsGenie
|
87
|
+
[alerts and alert fields](https://docs.opsgenie.com/docs/alerts-and-alert-fields) created?
|
88
|
+
|
89
|
+
### Message
|
90
|
+
|
91
|
+
The OpsGenie _message_ alert field is comprised of the Sensu client name, and
|
92
|
+
the Sensu check name, _e.g._:
|
93
|
+
```
|
94
|
+
web01 : check_mysql_access
|
95
|
+
```
|
96
|
+
|
97
|
+
### Teams
|
98
|
+
|
99
|
+
The OpsGenie _team_ alert field uses the values in the Sensu check configuration
|
100
|
+
if any, otherwise it uses the value from the handler configuration.
|
101
|
+
|
102
|
+
### Recipients
|
103
|
+
|
104
|
+
The OpsGenie _recipients_ alert field uses the values in the Sensu check
|
105
|
+
configuration if any, otherwise it uses the value from the handler
|
106
|
+
configuration.
|
107
|
+
|
108
|
+
### Alias
|
109
|
+
|
110
|
+
The OpsGenie _alias_ alert is field is comprised of the Sensu client name,
|
111
|
+
and the Sensu check name to create a unique key, _e.g._:
|
112
|
+
```
|
113
|
+
web01:check_mysql_access
|
114
|
+
```
|
115
|
+
Note that this can be changed via configuration; see notes below.
|
116
|
+
|
117
|
+
### Entity
|
118
|
+
|
119
|
+
The OpsGenie _entity_ alert field uses the Sensu client name.
|
120
|
+
|
121
|
+
### Description
|
122
|
+
|
123
|
+
The OpsGenie _description_ alert field is populated with the Sensu check output.
|
124
|
+
|
125
|
+
### Priority
|
126
|
+
|
127
|
+
The OpsGenie _priority_ alert field is not explicitly set; OpsGenie will thus
|
128
|
+
assign the default priority of "P3" to the alert.
|
129
|
+
|
130
|
+
|
131
|
+
## Configuration Notes
|
85
132
|
|
86
133
|
If the check definition uses the custom `alias` attribute, _e.g._:
|
87
134
|
```
|
data/bin/handler-opsgenie.rb
CHANGED
@@ -11,7 +11,7 @@ require 'json'
|
|
11
11
|
require 'erb'
|
12
12
|
|
13
13
|
class Opsgenie < Sensu::Handler
|
14
|
-
attr_reader :json_config, :message_template
|
14
|
+
attr_reader :json_config, :message_template, :verbose
|
15
15
|
|
16
16
|
OPSGENIE_URL = 'https://api.opsgenie.com/v2/alerts'.freeze
|
17
17
|
|
@@ -27,6 +27,12 @@ class Opsgenie < Sensu::Handler
|
|
27
27
|
long: '--template <file_path>',
|
28
28
|
default: nil
|
29
29
|
|
30
|
+
option :verbose,
|
31
|
+
description: 'Enable verbose/debugging output',
|
32
|
+
short: '-v',
|
33
|
+
long: '--verbose',
|
34
|
+
default: false
|
35
|
+
|
30
36
|
def handle
|
31
37
|
init
|
32
38
|
process
|
@@ -66,6 +72,11 @@ class Opsgenie < Sensu::Handler
|
|
66
72
|
puts "opsgenie -- timed out while attempting to #{@event['action']} a incident -- #{event_id}"
|
67
73
|
end
|
68
74
|
|
75
|
+
def description
|
76
|
+
return json_config['description'] unless json_config['description'].nil?
|
77
|
+
@event['check']['output'].chomp
|
78
|
+
end
|
79
|
+
|
69
80
|
def message
|
70
81
|
return @event['notification'] unless @event['notification'].nil?
|
71
82
|
return default_message if message_template.nil? || !File.exist?(message_template)
|
@@ -79,7 +90,7 @@ class Opsgenie < Sensu::Handler
|
|
79
90
|
end
|
80
91
|
|
81
92
|
def default_message
|
82
|
-
[@event['client']['name'], @event['check']['name']
|
93
|
+
[@event['client']['name'], @event['check']['name']].join(' : ')
|
83
94
|
end
|
84
95
|
|
85
96
|
def event_id
|
@@ -111,7 +122,7 @@ class Opsgenie < Sensu::Handler
|
|
111
122
|
post_to_opsgenie(:create,
|
112
123
|
alias: event_id,
|
113
124
|
message: message,
|
114
|
-
description:
|
125
|
+
description: description,
|
115
126
|
entity: client_name,
|
116
127
|
tags: tags,
|
117
128
|
recipients: json_config['recipients'],
|
@@ -145,6 +156,19 @@ class Opsgenie < Sensu::Handler
|
|
145
156
|
"#{encoded_alias}/close?identifierType=alias"
|
146
157
|
end
|
147
158
|
uri = URI.parse("#{OPSGENIE_URL}/#{uripath}")
|
159
|
+
|
160
|
+
if config[:verbose]
|
161
|
+
# Note that the ordering of these lines roughly follows the order
|
162
|
+
# alert fields are displayed in the OpsGenie web UI.
|
163
|
+
puts "URL: #{uri}"
|
164
|
+
puts "Message: #{params[:message]}"
|
165
|
+
puts "Tags: #{params[:tags]}"
|
166
|
+
puts "Entity: #{params[:entity]}"
|
167
|
+
puts "Teams: #{params[:teams]}"
|
168
|
+
puts "Alias: #{params[:alias]}"
|
169
|
+
puts "Description: #{params[:description]}"
|
170
|
+
end
|
171
|
+
|
148
172
|
http = Net::HTTP.new(uri.host, uri.port)
|
149
173
|
http.use_ssl = true
|
150
174
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
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.
|
4
|
+
version: 4.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: 2018-02-
|
11
|
+
date: 2018-02-21 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.6
|
271
271
|
signing_key:
|
272
272
|
specification_version: 4
|
273
273
|
summary: Sensu plugins for working with opsgenie
|