sensu-plugins-xmatters 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +85 -0
- data/bin/handler-xmatters.rb +85 -0
- data/lib/xmatters-sensu/version.rb +27 -0
- data/lib/xmatters-sensu.rb +58 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: badb87db7fe359954ae2c26cf30512876bcb7b1a
|
4
|
+
data.tar.gz: 39fcd32e76ca645d231dfbba91c8e1d8e8009edc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de6e564757688bf229bcb869956beb7a0f9b24018f09342fcc0f042239240964529f3a9ba992947dadce6ab626e4e3d60e238225a6dfae1d2b15af17bebef6ed
|
7
|
+
data.tar.gz: 5de15d28d6285b9c125ce011c7d2046bf6da69e46e2db1a8592a043788650b550b0abd21939f93220b8fb119a3a7664ffba4a0346b42122f2afe41d5a0b7de11
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dan Reich
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Sensu-Plugins-xMatters
|
2
|
+
|
3
|
+
## What is it?
|
4
|
+
|
5
|
+
This version of the integration is a simple sensu plugin with a single handler, found at [bin/handler-xmatters.rb](bin/handler-xmatters.rb). The handler will create a new event in xMatters via an inbound integration in the included Sensu Communication Plan.
|
6
|
+
|
7
|
+
## How does it work?
|
8
|
+
|
9
|
+
### Installation
|
10
|
+
|
11
|
+
Before installing the Sensu plugin, import the Sensu communication plan into your xMatters instance. You will need the URLs for the inbound and outbound integrations from the imported plan.
|
12
|
+
|
13
|
+
To install the integration, run the following command:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
sensu-install -p xmatters
|
17
|
+
```
|
18
|
+
|
19
|
+
### Configuration
|
20
|
+
|
21
|
+
#### Configuring a handler:
|
22
|
+
|
23
|
+
To configure a handler, use the following syntax:
|
24
|
+
|
25
|
+
```json
|
26
|
+
{
|
27
|
+
"handlers": {
|
28
|
+
"xmatters_handler": {
|
29
|
+
"type": "pipe",
|
30
|
+
"command": "handler-xmatters.rb"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
```
|
35
|
+
#### Create a default settings file:
|
36
|
+
|
37
|
+
To create a default settings file, use the following syntax, and replace the inbound_integration_url with the URL of the inbound integration in the Sensu communication plan:
|
38
|
+
|
39
|
+
```json
|
40
|
+
{
|
41
|
+
"xmatters": {
|
42
|
+
"inbound_integration_url": "https://company.instance.xmatters.com/api/integration/1/functions/uuid/triggers"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
To create multiple handlers that point to different integration URLS, use the following syntax:
|
48
|
+
|
49
|
+
```json
|
50
|
+
|
51
|
+
{
|
52
|
+
"handlers": {
|
53
|
+
"xmatters_handler": {
|
54
|
+
"type": "pipe",
|
55
|
+
"command": "handler-xmatters.rb -c xmatters_custom"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
{
|
61
|
+
"xmatters_custom": {
|
62
|
+
"inbound_integration_url": "https://company.instance.xmatters.com/api/integration/1/functions/uuid/triggers"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
71
|
+
|
72
|
+
## Development and Publishing
|
73
|
+
|
74
|
+
During development, to execute tests and perform additional linting and validation run the following command:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
rake
|
78
|
+
```
|
79
|
+
|
80
|
+
When ready to release a new version, run the following commands:
|
81
|
+
|
82
|
+
```sh
|
83
|
+
gem build sensu-plugins-xmatters.gemspec
|
84
|
+
gem push sensu-plugins-xmatters-x.y.z.gem
|
85
|
+
```
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# handler-xmatters.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This handler creates events in xMatters based on the Sensu event input.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux, Windows, BSD, Solaris, etc
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
# handler-xmatters.rb -c xmatters
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# xMatters alderaan@xmatters.com
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
25
|
+
# for details.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'sensu-handler'
|
29
|
+
require 'xmatters-sensu'
|
30
|
+
|
31
|
+
#
|
32
|
+
# xMatters
|
33
|
+
#
|
34
|
+
class XMattersHandler < Sensu::Handler
|
35
|
+
option :pattern,
|
36
|
+
description: 'Used to allow tests to run only, ignored in code',
|
37
|
+
long: '--pattern pattern',
|
38
|
+
required: false
|
39
|
+
option :config_name,
|
40
|
+
description: 'The name of the configuration',
|
41
|
+
short: '-c ConfigName',
|
42
|
+
long: '--config_name ConfigName',
|
43
|
+
required: false,
|
44
|
+
default: 'xmatters'
|
45
|
+
|
46
|
+
#
|
47
|
+
# The name of the configuration that will be used to find xMatters Settings
|
48
|
+
#
|
49
|
+
def config_name
|
50
|
+
@config_name ||= config[:config_name]
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# The xMatters Settings object
|
55
|
+
#
|
56
|
+
def xm_settings
|
57
|
+
@xm_settings ||= settings[config_name]
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# The integration url that will be used to create an xMatters Event
|
62
|
+
#
|
63
|
+
def integration_url
|
64
|
+
@integration_url ||= xm_settings['inbound_integration_url']
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Override
|
69
|
+
# If the action type is create, we will create an event in xMatters
|
70
|
+
# with the default properties payload to the configured inbound
|
71
|
+
# integration url in xMatters
|
72
|
+
#
|
73
|
+
def handle
|
74
|
+
xm_client = XMSensu::XMClient.new(integration_url)
|
75
|
+
payload = xm_client.get_default_properties(@event)
|
76
|
+
begin
|
77
|
+
case @event['action']
|
78
|
+
when 'create'
|
79
|
+
xm_client.send_event(payload)
|
80
|
+
when 'resolve'
|
81
|
+
puts 'xMatters Handler bypassing resolve'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# XMSensu
|
3
|
+
#
|
4
|
+
module XMSensu
|
5
|
+
#
|
6
|
+
# XMSensu::Version
|
7
|
+
#
|
8
|
+
module Version
|
9
|
+
#
|
10
|
+
# MAJOR Version
|
11
|
+
#
|
12
|
+
MAJOR = 0
|
13
|
+
#
|
14
|
+
# MINOR Version
|
15
|
+
#
|
16
|
+
MINOR = 0
|
17
|
+
#
|
18
|
+
# PATCH Version
|
19
|
+
#
|
20
|
+
PATCH = 4
|
21
|
+
|
22
|
+
#
|
23
|
+
# Formatted Version String
|
24
|
+
#
|
25
|
+
VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'xmatters-sensu/version'
|
2
|
+
|
3
|
+
#
|
4
|
+
# XMSensu
|
5
|
+
#
|
6
|
+
# Holder for common functionality
|
7
|
+
#
|
8
|
+
module XMSensu
|
9
|
+
#
|
10
|
+
# XMSensu::XMClient
|
11
|
+
#
|
12
|
+
# A class used for common xMatters logic
|
13
|
+
#
|
14
|
+
class XMClient
|
15
|
+
#
|
16
|
+
# Constructor
|
17
|
+
#
|
18
|
+
# integration_url is an inbound integration url from an xMatters Communication Plan
|
19
|
+
#
|
20
|
+
def initialize(integration_url, user = nil, pass = nil)
|
21
|
+
@user = user
|
22
|
+
@pass = pass
|
23
|
+
@uri = URI(integration_url)
|
24
|
+
@header = {
|
25
|
+
'Content-Type' => 'text/json'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Sends the properties to the configured integration url in the correct json format
|
31
|
+
#
|
32
|
+
def send_event(properties)
|
33
|
+
http = Net::HTTP.new(@uri.hostname, @uri.port)
|
34
|
+
request = Net::HTTP::Post.new(@uri.path, @header)
|
35
|
+
request.body = { properties: properties }.to_json
|
36
|
+
http.use_ssl = true
|
37
|
+
http.request(request)
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Gets a default set of properties from the event
|
42
|
+
#
|
43
|
+
def get_default_properties(event)
|
44
|
+
client = event['client']
|
45
|
+
check = event['check']
|
46
|
+
{
|
47
|
+
server_name: client['name'],
|
48
|
+
server_ip: client['address'],
|
49
|
+
subscriptions: client['subscriptions'].join(';'),
|
50
|
+
environment: client['environment'],
|
51
|
+
check_name: check['name'],
|
52
|
+
check_command: check['command'],
|
53
|
+
check_output: check['output'],
|
54
|
+
timestamp: event['timestamp'].inspect
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-xmatters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- xMatters
|
8
|
+
- Dan Reich
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sensu-plugin
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.4'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.4'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.14'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.14'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.5'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.5'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.40.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.40.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: webmock
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.3'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.3'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: colorize
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.8'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.8'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: yard
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.8'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.8'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: github-markup
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '1.3'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '1.3'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: redcarpet
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.2'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.2'
|
154
|
+
description: Provides a default xMatters handler and library that can be used to create
|
155
|
+
xMatters Events when events occur in Sensu
|
156
|
+
email:
|
157
|
+
- alderaan@xmatters.com
|
158
|
+
- dreich@xmatters.com
|
159
|
+
executables:
|
160
|
+
- handler-xmatters.rb
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files: []
|
163
|
+
files:
|
164
|
+
- LICENSE
|
165
|
+
- README.md
|
166
|
+
- bin/handler-xmatters.rb
|
167
|
+
- lib/xmatters-sensu.rb
|
168
|
+
- lib/xmatters-sensu/version.rb
|
169
|
+
homepage: https://github.com/xmatters/sensu-plugins-xmatters
|
170
|
+
licenses:
|
171
|
+
- MIT
|
172
|
+
metadata:
|
173
|
+
allowed_push_host: https://rubygems.org
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 2.6.13
|
191
|
+
signing_key:
|
192
|
+
specification_version: 4
|
193
|
+
summary: A Sensu plugin for xMatters
|
194
|
+
test_files: []
|