sensu-plugins-statuspage 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a0644a81510246346f22f3e469ec109a488e153c
4
+ data.tar.gz: 80a97fb3ce14e39f240f8990f04e13058ad4a92d
5
+ SHA512:
6
+ metadata.gz: 4be91ef39b545be6144550fe903537a5935510ad5ec48b4c55ff1b678bea2c9f74ffaf6c7ecb59106b2bd85ffb6a2d2479b53e10f23a73d161b80bc67983242f
7
+ data.tar.gz: 148063e0e66cd7876b621fa178b76eb4eed71922360edeb3bd97cef69b865a97220a5dc9089b1b185dc39482bbc675c88f5c1695cad1d8ca9a8f12592e55e2f4
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ; ���)�"t�(�h�y�lfPBH�U�(z95*���#s +T���E�!��g����P��bVH�K�Y�F�Ű%�qZ{{I�L,?0����60;ҕ�s\�
2
+ �h5�Y���6
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## Unreleased][unreleased]
7
+
8
+ ## [0.0.1] - 2015-07-04
9
+
10
+ ### Added
11
+ - initial release
12
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ ## Sensu-Plugins-statuspage
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-statuspage.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-statuspage)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-statuspage.svg)](http://badge.fury.io/rb/sensu-plugins-statuspage)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-statuspage/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-statuspage)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-statuspage/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-statuspage)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-statuspage.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-statuspage)
8
+ [ ![Codeship Status for sensu-plugins/sensu-plugins-statuspage](https://codeship.com/projects/b454e0b0-edb1-0132-0ba1-1efd3f886df2/status?branch=master)](https://codeship.com/projects/84066)
9
+
10
+ ## Functionality
11
+
12
+ **handler-statuspage**
13
+
14
+ Creates an issue on StatusPage.io and (optionally) updates a component status.
15
+
16
+ **metrics-statuspageio**
17
+
18
+ Sends graphite-style metrics to statuspage.io, for displaying public metrics. Note, this forks and is not meant for high-throughput. Rather, it is meant for high-value, low-throughput metrics for display on status page.
19
+
20
+ ## Files
21
+ * bin/handler-statuspage
22
+ * bin/metrics-statuspageio
23
+
24
+ ## Usage
25
+
26
+ **handler-statuspage**
27
+ ```
28
+ {
29
+ "statuspage": {
30
+ "api_key": "YOURAPIKEY",
31
+ "page_id": "YOURPAGEID"
32
+ }
33
+ }
34
+ ```
35
+
36
+ **metrics-statuspageio**
37
+ ```
38
+ {
39
+ "metrics-statuspageio": {
40
+ "api_key": "my_api_key",
41
+ "page_id": "my_page_id",
42
+ "metrics": {
43
+ "some.metric.identifier": "my_metric_id",
44
+ "another.metric.identifier": "another_metric_id"
45
+ }
46
+ }
47
+ }
48
+ ```
49
+ ## Installation
50
+
51
+ [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
52
+
53
+ ## Notes
54
+
55
+ As of this writing Redphone has not added StatusPage.io support to v0.0.6
56
+ You must manually build and install the gem:
57
+ ```
58
+ git clone https://github.com/portertech/redphone.git
59
+ cd redphone
60
+ gem build redphone.gemspec OR /opt/sensu/embedded/bin/gem build redphone.gemspec
61
+ gem install redphone-0.0.6.gem OR /opt/sensu/embedded/bin/gem install redphone-0.0.6.gem
62
+ ```
63
+
64
+ To update a component add a ```"component_id": "IDHERE"``` attribute to the corresponding check definition
65
+
66
+ Example:
67
+ ```
68
+ {
69
+ "checks": {
70
+ "check_sshd": {
71
+ "handlers": ["statuspage"],
72
+ "component_id": "IDHERE",
73
+ "command": "/etc/sensu/plugins/check-procs.rb -p sshd -C 1 ",
74
+ "interval": 60,
75
+ "subscribers": [ "default" ]
76
+ }
77
+ }
78
+ }
79
+ ```
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This handler creates and updates incidents and changes a component status (optional) for StatusPage.IO.
4
+ # Due to a bug with their API, please pair a Twitter account to your StatusPage even if you don't plan to tweet.
5
+ #
6
+ # Copyright 2011 Sonian, Inc <chefs@sonian.net>
7
+ # Copyright 2013 DISQUS, Inc.
8
+ # Updated by jfledvin with Basic Component Support 4/14/2015
9
+ #
10
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
11
+ # for details.
12
+
13
+ require 'sensu-handler'
14
+ require 'redphone/statuspage'
15
+
16
+ # main plugin class
17
+ class StatusPage < Sensu::Handler
18
+ def incident_key
19
+ @event['client']['name'] + '/' + @event['check']['name']
20
+ end
21
+
22
+ def handle
23
+ statuspage = Redphone::Statuspage.new(
24
+ page_id: settings['statuspage']['page_id'],
25
+ api_key: settings['statuspage']['api_key']
26
+ )
27
+ description = @event['notification'] || [@event['client']['name'], @event['check']['name'], @event['check']['output']].join(' : ')
28
+ begin
29
+ timeout(3) do
30
+ if @event['check'].key?('component_id')
31
+ status = case @event['action']
32
+ when 'create'
33
+ 'major_outage'
34
+ when 'resolve'
35
+ 'operational'
36
+ else # rubocop:disable all
37
+ nil
38
+ end
39
+ unless status.nil?
40
+ statuspage.update_component(
41
+ component_id: @event['check']['component_id'],
42
+ status: status)
43
+ end
44
+ end
45
+ response = case @event['action']
46
+ when 'create'
47
+ # #YELLOW
48
+ response = statuspage.create_realtime_incident( # rubocop:disable UselessAssignment, SpaceInsideParens
49
+ name: incident_key,
50
+ status: 'investigating',
51
+ wants_twitter_update: 'f',
52
+ message: "There has been a problem: #{description}."
53
+ )
54
+ when 'resolve'
55
+ incident_id = nil
56
+ statuspage.get_all_incidents.each do |incident|
57
+ if incident['name'] == incident_key
58
+ incident_id = incident['id']
59
+ break
60
+ end
61
+ end
62
+ # #YELLOW
63
+ response = statuspage.update_incident( # rubocop:disable UselessAssignment, SpaceInsideParens
64
+ name: "Problem with #{incident_key} has been resolved.",
65
+ wants_twitter_update: 'f',
66
+ status: 'resolved',
67
+ incident_id: incident_id
68
+ )
69
+ end
70
+ if (response['status'] == 'investigating' || @event['action'] == 'create') || (response['status'] == 'resolved' || @event['action'] == 'resolve')
71
+ puts 'statuspage -- ' + @event['action'].capitalize + 'd incident -- ' + incident_key
72
+ else
73
+ puts 'statuspage -- failed to ' + @event['action'] + ' incident -- ' + incident_key
74
+ end
75
+ end
76
+ rescue Timeout::Error
77
+ puts 'statuspage -- timed out while attempting to ' + @event['action'] + ' a incident -- ' + incident_key
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright 2013 Nick Stielau
4
+ #
5
+ # This handler will send graphite-style metrics to statuspage.io, for
6
+ # displaying public metrics. Note, this forks and is not meant for
7
+ # high-throughput. Rather, it is meant for high-value, low-throughput
8
+ # metrics for display on status page.
9
+ #
10
+ # Depends on httpary gem
11
+ # gem install httparty
12
+ #
13
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
14
+ # for details.
15
+
16
+ require 'sensu-handler'
17
+ require 'httparty'
18
+
19
+ # main plugin class
20
+ class StatusPageIOMetrics < Sensu::Handler
21
+ # override filters from Sensu::Handler. not appropriate for metric handlers
22
+ def filter; end
23
+
24
+ def send_metric(value, timestamp, metric_id)
25
+ # puts "Sending #{value} #{timestamp} #{metric_id}"
26
+ timeout(3) do
27
+ HTTParty.post(
28
+ "https://api.statuspage.io/v1/pages/#{@page_id}/metrics/#{metric_id}/data.json",
29
+ headers: { 'Authorization' => "OAuth #{@api_key}" },
30
+ body: {
31
+ data: {
32
+ timestamp: timestamp,
33
+ value: value.to_f
34
+ }
35
+ }
36
+ )
37
+ end
38
+ rescue Timeout::Error
39
+ puts 'statuspageio -- timed out while sending metrics'
40
+ rescue => error
41
+ puts "statuspageio -- failed to send metric #{metric_id} : #{error}"
42
+ end
43
+
44
+ def handle
45
+ # Grab page_id and api_key from dashboard
46
+ @api_key = settings['handlers']['statuspageio_metrics']['api_key']
47
+ @page_id = settings['handlers']['statuspageio_metrics']['page_id']
48
+
49
+ # Get a dict of metric_from_output => metric_ids
50
+ # This allows the re-use of standard metrics plugins that can be mapped to
51
+ # statuspage io metrics
52
+ @metrics = settings['handlers']['statuspageio_metrics']['metrics'] || {}
53
+
54
+ # Split graphite-style metrics
55
+ @event['check']['output'].split(/\n/).each do |m|
56
+ metric, value, timestamp = m.split
57
+ # Get the metric ID from the check, or from the global mapping
58
+ metric_id = @event['check']['statuspageio_metric_id'] || @metrics[metric]
59
+ send_metric(value, timestamp, metric_id) if metric_id
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ module SensuPluginsStatuspage
3
+ # This defines the version of the gem
4
+ module Version
5
+ MAJOR = 0
6
+ MINOR = 0
7
+ PATCH = 1
8
+
9
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-statuspage/version'
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+
metadata ADDED
@@ -0,0 +1,248 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-statuspage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
14
+ am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
16
+ CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
18
+ CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
19
+ zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
20
+ qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
21
+ k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
22
+ oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
23
+ 0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
25
+ QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
26
+ MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
27
+ rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
28
+ UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
29
+ JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
30
+ 8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
+ HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
+ -----END CERTIFICATE-----
33
+ date: 2015-07-04 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sensu-plugin
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.1.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.1.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: httparty
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.13.5
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.13.5
63
+ - !ruby/object:Gem::Dependency
64
+ name: redphone
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.0.6
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.0.6
77
+ - !ruby/object:Gem::Dependency
78
+ name: bundler
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.7'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.7'
91
+ - !ruby/object:Gem::Dependency
92
+ name: codeclimate-test-reporter
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.4'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.4'
105
+ - !ruby/object:Gem::Dependency
106
+ name: github-markup
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.3'
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.3'
119
+ - !ruby/object:Gem::Dependency
120
+ name: pry
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.10'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0.10'
133
+ - !ruby/object:Gem::Dependency
134
+ name: rubocop
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - '='
138
+ - !ruby/object:Gem::Version
139
+ version: '0.30'
140
+ type: :development
141
+ prerelease: false
142
+ version_requirements: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '='
145
+ - !ruby/object:Gem::Version
146
+ version: '0.30'
147
+ - !ruby/object:Gem::Dependency
148
+ name: rspec
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '3.1'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '3.1'
161
+ - !ruby/object:Gem::Dependency
162
+ name: rake
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '10.0'
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '10.0'
175
+ - !ruby/object:Gem::Dependency
176
+ name: redcarpet
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '3.2'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - "~>"
187
+ - !ruby/object:Gem::Version
188
+ version: '3.2'
189
+ - !ruby/object:Gem::Dependency
190
+ name: yard
191
+ requirement: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - "~>"
194
+ - !ruby/object:Gem::Version
195
+ version: '0.8'
196
+ type: :development
197
+ prerelease: false
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - "~>"
201
+ - !ruby/object:Gem::Version
202
+ version: '0.8'
203
+ description: Sensu statuspage plugins
204
+ email: "<sensu-users@googlegroups.com>"
205
+ executables:
206
+ - metrics-statuspageio.rb
207
+ - handler-statuspage.rb
208
+ extensions: []
209
+ extra_rdoc_files: []
210
+ files:
211
+ - CHANGELOG.md
212
+ - LICENSE
213
+ - README.md
214
+ - bin/handler-statuspage.rb
215
+ - bin/metrics-statuspageio.rb
216
+ - lib/sensu-plugins-statuspage.rb
217
+ - lib/sensu-plugins-statuspage/version.rb
218
+ homepage: https://github.com/sensu-plugins/sensu-plugins-statuspage
219
+ licenses:
220
+ - MIT
221
+ metadata:
222
+ maintainer: sensu-plugin
223
+ development_status: active
224
+ production_status: unstable - testing recommended
225
+ release_draft: 'false'
226
+ release_prerelease: 'false'
227
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
228
+ in /etc/default/sensu
229
+ rdoc_options: []
230
+ require_paths:
231
+ - lib
232
+ required_ruby_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: 1.9.3
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ requirements: []
243
+ rubyforge_project:
244
+ rubygems_version: 2.4.6
245
+ signing_key:
246
+ specification_version: 4
247
+ summary: Sensu plugins for statuspage
248
+ test_files: []
metadata.gz.sig ADDED
Binary file