runscope_statuspage 0.1.4 → 0.1.5
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/.gitignore +9 -9
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +14 -5
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +7 -7
- data/lib/runscope_statuspage.rb +284 -237
- data/lib/runscope_statuspage/version.rb +3 -3
- data/runscope_statuspage.gemspec +24 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 876152fb45917929d74512f7a698af3aab184bf4
|
4
|
+
data.tar.gz: 6e38d356acdd2720fd07db9327cb6133a79e0552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61be1407248d38797d75408e882bc21ebb969aaf4ca92c57fe770d1067efcc49a551f49aee414501a09699b88715d2e403f7816adc2fb7666b62fde573c981f0
|
7
|
+
data.tar.gz: 9cf417c8e2b97c50a973d9aa9dda83a7a10c054cafdddd00a6b768c1dec33f5548199e806c72c854f8e74cdaf96abe370dd8b52e842b26140cca824b58879ac4
|
data/.gitignore
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'httparty'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in runscope_statuspage.gemspec
|
6
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'httparty'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in runscope_statuspage.gemspec
|
6
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 David Stancu
|
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.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 David Stancu
|
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
CHANGED
@@ -31,21 +31,24 @@ In a nutshell, each call will grab metrics from RunScope then send them over to
|
|
31
31
|
```ruby
|
32
32
|
opts = {:status => "page status (either 'investigating|identified|monitoring|resolved')",
|
33
33
|
:twitter_update => 'do you want to post status to twitter (bool)',
|
34
|
-
:fail_on => 'number of failures to induce statuspage update (int, default 0)'
|
34
|
+
:fail_on => 'number of failures to induce statuspage update (int, default 0)',
|
35
|
+
:no_sp => skip statuspage.io report and return data}
|
35
36
|
```
|
36
37
|
- *report_buckets:* Report all radars of buckets in list.
|
37
38
|
```ruby
|
38
39
|
opts = {:bucket_names => 'list of names of buckets containing radars',
|
39
40
|
:status => "page status (either 'investigating|identified|monitoring|resolved')",
|
40
41
|
:twitter_update => 'do you want to post status to twitter (bool)',
|
41
|
-
:fail_on => 'number of failures to induce statuspage update (int, default 0)'
|
42
|
+
:fail_on => 'number of failures to induce statuspage update (int, default 0)',
|
43
|
+
:no_sp => skip statuspage.io report and return data}
|
42
44
|
```
|
43
45
|
- *report_bucket:* Report all radars in bucket.
|
44
46
|
```ruby
|
45
47
|
opts = {:bucket_name => 'name of bucket containing radars',
|
46
48
|
:status => "page status (either 'investigating|identified|monitoring|resolved')",
|
47
49
|
:twitter_update => 'do you want to post status to twitter (bool)',
|
48
|
-
:fail_on => 'number of failures to induce statuspage update (int, default 0)'
|
50
|
+
:fail_on => 'number of failures to induce statuspage update (int, default 0)',
|
51
|
+
:no_sp => skip statuspage.io report and return data}
|
49
52
|
```
|
50
53
|
- *report_radars:* Report radars in list for given bucket.
|
51
54
|
```ruby
|
@@ -53,7 +56,8 @@ opts = {:bucket_name => 'name of bucket containing radars',
|
|
53
56
|
:radar_names => 'list of names of radars within bucket',
|
54
57
|
:status => "page status (either 'investigating|identified|monitoring|resolved')",
|
55
58
|
:twitter_update => 'do you want to post status to twitter (bool)',
|
56
|
-
:fail_on => 'number of failures to induce statuspage update (int, default 0)'
|
59
|
+
:fail_on => 'number of failures to induce statuspage update (int, default 0)',
|
60
|
+
:no_sp => skip statuspage.io report and return data}
|
57
61
|
```
|
58
62
|
- *report_radar:* Report one radar in bucket.
|
59
63
|
```ruby
|
@@ -61,7 +65,8 @@ opts = {:bucket_name => 'name of bucket containing radars',
|
|
61
65
|
:radar_name => 'name of radar within bucket',
|
62
66
|
:status => "page status (either 'investigating|identified|monitoring|resolved')",
|
63
67
|
:twitter_update => 'do you want to post status to twitter (bool)',
|
64
|
-
:fail_on => 'number of failures to induce statuspage update (int, default 0)'
|
68
|
+
:fail_on => 'number of failures to induce statuspage update (int, default 0)',
|
69
|
+
:no_sp => skip statuspage.io report and return data}
|
65
70
|
```
|
66
71
|
|
67
72
|
#### Important Notes
|
@@ -104,6 +109,10 @@ Usage:
|
|
104
109
|
|
105
110
|
## Changelog
|
106
111
|
|
112
|
+
0.1.5
|
113
|
+
* Added `:no_sp` to available options so that data can be returned instead of posting to statuspage.io. Useful for SMS notifications.
|
114
|
+
* Fix bug where gem crashes when a key with a null value is used in the incident strings.
|
115
|
+
|
107
116
|
0.1.4
|
108
117
|
* Added attr_accessor for `@rs` and `@sp`.
|
109
118
|
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "runscope_statuspage"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "runscope_statuspage"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
|
5
|
-
bundle install
|
6
|
-
|
7
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
|
5
|
+
bundle install
|
6
|
+
|
7
|
+
# Do any other automated setup that you need to do here
|
data/lib/runscope_statuspage.rb
CHANGED
@@ -1,237 +1,284 @@
|
|
1
|
-
require_relative 'runscope_statuspage/version'
|
2
|
-
require_relative 'runscope_statuspage/exceptions'
|
3
|
-
require_relative 'runscope_statuspage/runscope_api'
|
4
|
-
require_relative 'runscope_statuspage/statuspage_api'
|
5
|
-
|
6
|
-
module RunscopeStatuspage
|
7
|
-
# Let Ruby write boring getters and setters
|
8
|
-
class << self; attr_accessor :rs_key, :sp_key, :sp_page, :name, :msg, :rs, :sp; end
|
9
|
-
|
10
|
-
# API credentials and IDs
|
11
|
-
@rs_key, @sp_key, @sp_page = ''
|
12
|
-
|
13
|
-
# Verbage sent to statuspage
|
14
|
-
@name = 'Suspected issues with /name/'
|
15
|
-
@msg = 'Our automated test detected an issue while testing the /description/ endpoint. We are currently investigating this issue.'
|
16
|
-
|
17
|
-
# As the user may decide (for whatever reason)
|
18
|
-
# to change API keys after one request, we re-initialize
|
19
|
-
# these objects.
|
20
|
-
def self.reinit_rest
|
21
|
-
@rs = RunscopeAPI.new(@rs_key)
|
22
|
-
@sp = StatuspageAPI.new(@sp_key)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Splice radar hash values from keys defined in
|
26
|
-
# @name and @msg.
|
27
|
-
def self.parameterize(radar)
|
28
|
-
rname = @name
|
29
|
-
rmsg = @msg
|
30
|
-
|
31
|
-
@name.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
|
32
|
-
set.each do |token|
|
33
|
-
if radar.has_key?(token)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
@
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
1
|
+
require_relative 'runscope_statuspage/version'
|
2
|
+
require_relative 'runscope_statuspage/exceptions'
|
3
|
+
require_relative 'runscope_statuspage/runscope_api'
|
4
|
+
require_relative 'runscope_statuspage/statuspage_api'
|
5
|
+
|
6
|
+
module RunscopeStatuspage
|
7
|
+
# Let Ruby write boring getters and setters
|
8
|
+
class << self; attr_accessor :rs_key, :sp_key, :sp_page, :name, :msg, :rs, :sp; end
|
9
|
+
|
10
|
+
# API credentials and IDs
|
11
|
+
@rs_key, @sp_key, @sp_page = ''
|
12
|
+
|
13
|
+
# Verbage sent to statuspage
|
14
|
+
@name = 'Suspected issues with /name/'
|
15
|
+
@msg = 'Our automated test detected an issue while testing the /description/ endpoint. We are currently investigating this issue.'
|
16
|
+
|
17
|
+
# As the user may decide (for whatever reason)
|
18
|
+
# to change API keys after one request, we re-initialize
|
19
|
+
# these objects.
|
20
|
+
def self.reinit_rest
|
21
|
+
@rs = RunscopeAPI.new(@rs_key)
|
22
|
+
@sp = StatuspageAPI.new(@sp_key)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Splice radar hash values from keys defined in
|
26
|
+
# @name and @msg.
|
27
|
+
def self.parameterize(radar)
|
28
|
+
rname = @name
|
29
|
+
rmsg = @msg
|
30
|
+
|
31
|
+
@name.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
|
32
|
+
set.each do |token|
|
33
|
+
if radar.has_key?(token)
|
34
|
+
next if radar[:token].nil?
|
35
|
+
rname = rname.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
@msg.scan(/.*?(\/)([A-Za-z]*)(\/)/).each do |set|
|
41
|
+
set.each do |token|
|
42
|
+
if radar.has_key?(token)
|
43
|
+
next if radar[:token].nil?
|
44
|
+
rmsg = rmsg.sub!("/#{token}/", radar[token]) unless (token == "/" and token.length == 1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return rname, rmsg
|
50
|
+
end
|
51
|
+
|
52
|
+
# Update status page with all radars, from all buckets.
|
53
|
+
# An error will most likely be thrown if you have empty buckets.
|
54
|
+
#
|
55
|
+
# Parameters: {:status => page status (either 'investigating|identified|monitoring|resolved'),
|
56
|
+
# :twitter_update => do you want to post status to twitter (bool),
|
57
|
+
# :fail_on => number of failures to induce statuspage update (int, default 0),
|
58
|
+
# :no_sp => skip statuspage.io report and return data}
|
59
|
+
def self.report_everything(opts={})
|
60
|
+
raise MissingArgumentException.new, 'report_everything is missing arguments' \
|
61
|
+
if not (opts.key?(:status) or opts.key?(:twitter_update))
|
62
|
+
|
63
|
+
opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
|
64
|
+
opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
|
65
|
+
|
66
|
+
failed_radars = []
|
67
|
+
event_info = []
|
68
|
+
|
69
|
+
reinit_rest
|
70
|
+
@rs.buckets.each do |bucket|
|
71
|
+
@rs.radars(bucket['key']).each do |radar|
|
72
|
+
begin
|
73
|
+
if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
|
74
|
+
failed_radars.push radar
|
75
|
+
end
|
76
|
+
rescue RunscopeAPIException => r
|
77
|
+
p r
|
78
|
+
next
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if failed_radars.length >= opts[:fail_on]
|
84
|
+
failed_radars.each do |radar|
|
85
|
+
data = *parameterize(radar)
|
86
|
+
|
87
|
+
@sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
|
88
|
+
event_info.push data if opts[:no_sp]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
event_info if opts[:no_sp]
|
93
|
+
end
|
94
|
+
|
95
|
+
# Update status page with one radar, from one bucket.
|
96
|
+
#
|
97
|
+
# Parameters: {:bucket_name => name of bucket containing radars,
|
98
|
+
# :radar_name => name of radar within bucket,
|
99
|
+
# :status => page status (either 'investigating|identified|monitoring|resolved'),
|
100
|
+
# :twitter_update => do you want to post status to twitter (bool),
|
101
|
+
# :fail_on => number of failures to induce statuspage update (int, default 0),
|
102
|
+
# :no_sp => skip statuspage.io report and return data}
|
103
|
+
def self.report_radar(opts = {})
|
104
|
+
raise MissingArgumentException.new, 'report_radar is missing arguments' \
|
105
|
+
if not (opts.key?(:status) or opts.key?(:twitter_update) \
|
106
|
+
or opts.key?(:bucket_name) or opts.key?(:radar_name))
|
107
|
+
|
108
|
+
opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
|
109
|
+
opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
|
110
|
+
|
111
|
+
failed_radars = []
|
112
|
+
event_info = []
|
113
|
+
|
114
|
+
reinit_rest
|
115
|
+
@rs.buckets.each do |bucket|
|
116
|
+
if bucket['name'] == bucket_name
|
117
|
+
@rs.radars(bucket['key']).each do |radar|
|
118
|
+
begin
|
119
|
+
if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and radar['name'] == radar_name
|
120
|
+
failed_radars.push radar
|
121
|
+
end
|
122
|
+
rescue RunscopeAPIException => r
|
123
|
+
p r
|
124
|
+
next
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if failed_radars.length >= opts[:fail_on]
|
131
|
+
failed_radars.each do |radar|
|
132
|
+
data = *parameterize(radar)
|
133
|
+
|
134
|
+
@sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
|
135
|
+
event_info.push data if opts[:no_sp]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
event_info if opts[:no_sp]
|
140
|
+
end
|
141
|
+
|
142
|
+
# Update status page with list of radars, from one bucket.
|
143
|
+
#
|
144
|
+
# Parameters: {:bucket_name => name of bucket containing radars,
|
145
|
+
# :radar_names => list of names of radars within bucket,
|
146
|
+
# :status => page status (either 'investigating|identified|monitoring|resolved'),
|
147
|
+
# :twitter_update => do you want to post status to twitter (bool),
|
148
|
+
# :fail_on => number of failures to induce statuspage update (int, default 0),
|
149
|
+
# :no_sp => skip statuspage.io report and return data}
|
150
|
+
def self.report_radars(opts = {})
|
151
|
+
raise MissingArgumentException.new, 'report_radars is missing arguments' \
|
152
|
+
if not (opts.key?(:status) or opts.key?(:twitter_update) \
|
153
|
+
or opts.key?(:bucket_name) or opts.key?(:radar_names))
|
154
|
+
|
155
|
+
opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
|
156
|
+
opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
|
157
|
+
|
158
|
+
failed_radars = []
|
159
|
+
event_info = []
|
160
|
+
|
161
|
+
reinit_rest
|
162
|
+
@rs.buckets.each do |bucket|
|
163
|
+
if bucket['name'] == opts[:bucket_name]
|
164
|
+
@rs.radars(bucket['key']).each do |radar|
|
165
|
+
begin
|
166
|
+
if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass' and opts[:radar_names].include?(radar['name'])
|
167
|
+
failed_radars.push radar
|
168
|
+
end
|
169
|
+
rescue RunscopeAPIException => r
|
170
|
+
p r
|
171
|
+
next
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
if failed_radars.length >= opts[:fail_on]
|
178
|
+
failed_radars.each do |radar|
|
179
|
+
data = *parameterize(radar)
|
180
|
+
|
181
|
+
@sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
|
182
|
+
event_info.push data if opts[:no_sp]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
event_info if opts[:no_sp]
|
187
|
+
end
|
188
|
+
|
189
|
+
# Update status page with all radars under passed
|
190
|
+
# bucket name.
|
191
|
+
#
|
192
|
+
# Parameters: {:bucket_name => name of bucket containing radars,
|
193
|
+
# :status => page status (either 'investigating|identified|monitoring|resolved'),
|
194
|
+
# :twitter_update => do you want to post status to twitter (bool),
|
195
|
+
# :fail_on => number of failures to induce statuspage update (int, default 0),
|
196
|
+
# :no_sp => skip statuspage.io report and return data}
|
197
|
+
def self.report_bucket(opts={})
|
198
|
+
raise MissingArgumentException.new, 'report_bucket is missing arguments' \
|
199
|
+
if not (opts.key?(:status) or opts.key?(:twitter_update) \
|
200
|
+
or opts.key?(:bucket_name))
|
201
|
+
|
202
|
+
opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
|
203
|
+
opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
|
204
|
+
|
205
|
+
failed_radars = []
|
206
|
+
event_info = []
|
207
|
+
|
208
|
+
reinit_rest
|
209
|
+
@rs.buckets.each do |bucket|
|
210
|
+
if bucket['name'] == opts[:bucket_name]
|
211
|
+
@rs.radars(bucket['key']).each do |radar|
|
212
|
+
begin
|
213
|
+
if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
|
214
|
+
failed_radars.push radar
|
215
|
+
end
|
216
|
+
rescue RunscopeAPIException => r
|
217
|
+
p r
|
218
|
+
next
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
if failed_radars.length >= opts[:fail_on]
|
225
|
+
failed_radars.each do |radar|
|
226
|
+
data = *parameterize(radar)
|
227
|
+
|
228
|
+
@sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
|
229
|
+
event_info.push data if opts[:no_sp]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
event_info if opts[:no_sp]
|
234
|
+
end
|
235
|
+
|
236
|
+
# Update status page with all radars under the specified
|
237
|
+
# buckets
|
238
|
+
#
|
239
|
+
# Parameters: {:bucket_names => list of names of buckets containing radars,
|
240
|
+
# :status => page status (either 'investigating|identified|monitoring|resolved'),
|
241
|
+
# :twitter_update => do you want to post status to twitter (bool),
|
242
|
+
# :fail_on => number of failures to induce statuspage update (int, default 0),
|
243
|
+
# :no_sp => skip statuspage.io report and return data}
|
244
|
+
def self.report_buckets(bucket_names, status, twitter_update)
|
245
|
+
raise MissingArgumentException.new, 'report_buckets is missing arguments' \
|
246
|
+
if not (opts.key?(:status) or opts.key?(:twitter_update) \
|
247
|
+
or opts.key?(:bucket_name))
|
248
|
+
|
249
|
+
opts[:fail_on] = opts.key?(:fail_on) ? opts[:fail_on] : 0
|
250
|
+
opts[:no_sp] = opts.key?(:no_sp) ? opts[:no_sp] : false
|
251
|
+
|
252
|
+
failed_radars = []
|
253
|
+
event_info = []
|
254
|
+
|
255
|
+
reinit_rest
|
256
|
+
|
257
|
+
@rs.buckets.each do |bucket|
|
258
|
+
if opts[:bucket_names].include?(bucket['name'])
|
259
|
+
@rs.radars(bucket['key']).each do |radar|
|
260
|
+
begin
|
261
|
+
if @rs.latest_radar_result(bucket['key'], radar['uuid'])['result'] != 'pass'
|
262
|
+
failed_radars.push radar
|
263
|
+
end
|
264
|
+
rescue RunscopeAPIException => r
|
265
|
+
p r
|
266
|
+
next
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
if failed_radars.length >= opts[:fail_on]
|
273
|
+
failed_radars.each do |radar|
|
274
|
+
data = *parameterize(radar)
|
275
|
+
|
276
|
+
@sp.create_realtime_incident(@sp_page, data.concat([opts[:status], opts[:twitter_update]])) if not opts[:no_sp]
|
277
|
+
event_info.push data if opts[:no_sp]
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
event_info if opts[:no_sp]
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module RunscopeStatuspage
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module RunscopeStatuspage
|
2
|
+
VERSION = '0.1.5'
|
3
|
+
end
|
data/runscope_statuspage.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'runscope_statuspage/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'runscope_statuspage'
|
8
|
-
spec.version = RunscopeStatuspage::VERSION
|
9
|
-
spec.authors = ['David Stancu']
|
10
|
-
spec.email = ['dstancu@nyu.edu']
|
11
|
-
|
12
|
-
|
13
|
-
spec.summary = 'Push RunScope data to StatusPage.io'
|
14
|
-
spec.description = 'Get test data from RunScope and easily report incidents to StatusPage.io, all with one gem.'
|
15
|
-
spec.homepage = 'https://github.com/mach-kernel/runscope_statuspage'
|
16
|
-
spec.license = 'MIT'
|
17
|
-
|
18
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.8'
|
23
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'runscope_statuspage/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'runscope_statuspage'
|
8
|
+
spec.version = RunscopeStatuspage::VERSION
|
9
|
+
spec.authors = ['David Stancu']
|
10
|
+
spec.email = ['dstancu@nyu.edu']
|
11
|
+
|
12
|
+
|
13
|
+
spec.summary = 'Push RunScope data to StatusPage.io'
|
14
|
+
spec.description = 'Get test data from RunScope and easily report incidents to StatusPage.io, all with one gem.'
|
15
|
+
spec.homepage = 'https://github.com/mach-kernel/runscope_statuspage'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runscope_statuspage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Stancu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.2.
|
82
|
+
rubygems_version: 2.2.3
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Push RunScope data to StatusPage.io
|