pingdom-cap 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.rvmrc +1 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +20 -0
- data/README.md +105 -0
- data/Rakefile +22 -0
- data/bin/pingdom-cap +3 -0
- data/features/pingdom-cap_executable.feature +24 -0
- data/features/step_definitions/erbify_steps.rb +6 -0
- data/features/support/env.rb +4 -0
- data/fixtures/cassettes/pause.yml +93 -0
- data/fixtures/cassettes/status.yml +105 -0
- data/fixtures/cassettes/status_after_pause.yml +56 -0
- data/fixtures/cassettes/status_after_unpause.yml +56 -0
- data/fixtures/cassettes/unpause.yml +93 -0
- data/lib/pingdom_cap.rb +4 -0
- data/lib/pingdom_cap/app.rb +20 -0
- data/lib/pingdom_cap/capistrano.rb +48 -0
- data/lib/pingdom_cap/client.rb +84 -0
- data/lib/pingdom_cap/version.rb +4 -0
- data/pingdom-cap.gemspec +34 -0
- data/spec/pingdom_cap/capistrano_spec.rb +44 -0
- data/spec/pingdom_cap/client_spec.rb +78 -0
- data/spec/spec_helper.rb +21 -0
- metadata +231 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Iora Health
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# pingdom-cap
|
2
|
+
|
3
|
+
pingdom-cap provides Capistrano tasks that can pause and unpause Pingdom checks.
|
4
|
+
|
5
|
+
For example, during a deploy, you probably don't want an email from Pingdom telling
|
6
|
+
you that your server is unavailable.
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
Add the pingdom-cap gem to your Gemfile:
|
11
|
+
|
12
|
+
gem 'pingdom-cap'
|
13
|
+
|
14
|
+
Then from your project's RAILS_ROOT, and in your development environment, run:
|
15
|
+
|
16
|
+
bundle install
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
You may configure pingdom_cap with Capistrano variables or with environment variables.
|
21
|
+
|
22
|
+
Capistrano variables method: Set the following variables in your Capistrano deploy.rb script:
|
23
|
+
|
24
|
+
set :pingdom_username, 'john@example.com'
|
25
|
+
set :pingdom_password, '123456'
|
26
|
+
set :pingdom_key, 'your-pingdom-key'
|
27
|
+
set :pingdom_check_name, 'check-name'
|
28
|
+
|
29
|
+
Environment variables way: Set the environment variables PINGDOM_USERNAME, PINGDOM_PASSWORD,
|
30
|
+
PINGDOM_KEY, and PINGDOM_CHECK_NAME.
|
31
|
+
|
32
|
+
The environment variables will take priority over the Capistrano variables, providing a means
|
33
|
+
to override.
|
34
|
+
|
35
|
+
NOTE: To acquire an API key for Pingdom, go here: https://pp.pingdom.com/index.php/member/api/restadd
|
36
|
+
|
37
|
+
(The Pingdom docs say: The key "is supposed to be unique on an application basis, not user basis.
|
38
|
+
This means that if you produce an application and then distribute it to the public, all users
|
39
|
+
of this application should use the same application key" (http://www.pingdom.com/services/api-documentation-rest/).
|
40
|
+
However, since Github projects are typically forked, we don't supply our key, and consider your
|
41
|
+
use of this gem to be a separate application. So get your own key.)
|
42
|
+
|
43
|
+
With these set, you can now type
|
44
|
+
|
45
|
+
cap pingdom:pause
|
46
|
+
cap pingdom:unpause
|
47
|
+
|
48
|
+
The first command with pause the check for 'check-name' and the second will unpause
|
49
|
+
the same check. Additionally, there is a task that will dump the status of a check
|
50
|
+
to the console:
|
51
|
+
|
52
|
+
cap pingdom:status
|
53
|
+
|
54
|
+
Or you can use before and/or after hooks to trigger these tasks as needed:
|
55
|
+
|
56
|
+
before 'deploy:migrations', 'pingdom:pause'
|
57
|
+
after 'deploy:migrations', 'pingdom:unpause'
|
58
|
+
|
59
|
+
## Bonus: Command-line application
|
60
|
+
|
61
|
+
The gem ships with a command-line application named: pingdom-cap
|
62
|
+
|
63
|
+
The usage is:
|
64
|
+
|
65
|
+
pingdom-cap check-name [status | pause | unpause]
|
66
|
+
|
67
|
+
To set the username, password, and key, use the environment variables as described above.
|
68
|
+
|
69
|
+
We added the command-line application because sometimes things go wrong. For example, it
|
70
|
+
may happen that Pingdom is broken, and your attempt to "unpause" fails. If that happens,
|
71
|
+
you probably want a means to unpause manually; in that case, use the command-line application.
|
72
|
+
|
73
|
+
## Testing
|
74
|
+
|
75
|
+
To run the specs,
|
76
|
+
|
77
|
+
bundle exec rake
|
78
|
+
|
79
|
+
The Cucumber integration tests are all marked with @slow_process and are excluded in the rake task because they conduct a real round-trip with the server. To run them, set the environment variables (as above) and run Cucumber directly. For example,
|
80
|
+
|
81
|
+
PINGDOM_CHECK_NAME="check-name" PINGDOM_USERNAME="john@example.com" \
|
82
|
+
PINGDOM_PASSWORD="123456" PINGDOM_KEY="your-pingdom-key" bundle exec cucumber
|
83
|
+
|
84
|
+
The specs use the VCR gem to verify HTTP requests and responses. To re-create the fixtures:
|
85
|
+
|
86
|
+
rm fixtures/cassettes/*
|
87
|
+
PINGDOM_CHECK_NAME="check-name" PINGDOM_USERNAME="john@example.com" \
|
88
|
+
PINGDOM_PASSWORD="123456" PINGDOM_KEY="your-pingdom-key" bundle exec rake
|
89
|
+
|
90
|
+
If you fork and generate new VCR cassettes, either don't check them in or obfuscate them,
|
91
|
+
because they will contain your credentials.
|
92
|
+
|
93
|
+
## Contributing to pingdom-cap
|
94
|
+
|
95
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
96
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
97
|
+
* Fork the project.
|
98
|
+
* Start a feature/bugfix branch.
|
99
|
+
* Commit and push until you are happy with your contribution.
|
100
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
101
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
102
|
+
|
103
|
+
## Copyright
|
104
|
+
|
105
|
+
Copyright (c) 2012 Iora Health. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
desc 'Default: run the specs.'
|
7
|
+
task :default => [:spec, :cucumber]
|
8
|
+
|
9
|
+
desc 'Test the pingdom_cap gem.'
|
10
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
11
|
+
t.rspec_opts = ['--color', "--format progress"]
|
12
|
+
t.pattern = 'spec/pingdom_cap*/**/*_spec.rb'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run cucumber features"
|
16
|
+
Cucumber::Rake::Task.new do |t|
|
17
|
+
t.cucumber_opts = [
|
18
|
+
'--tags', '~@wip',
|
19
|
+
'--tags', '~@slow_process',
|
20
|
+
'--format', (ENV['CUCUMBER_FORMAT'] || 'progress')
|
21
|
+
]
|
22
|
+
end
|
data/bin/pingdom-cap
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: pingdom-cap executable
|
2
|
+
|
3
|
+
In order to get my Pingdom checks the way I want
|
4
|
+
As a developer familiar with the command line
|
5
|
+
I want to be able to exercise Pingdom from the command line
|
6
|
+
|
7
|
+
@slow_process
|
8
|
+
Scenario: Status check
|
9
|
+
When (erb) I successfully run `pingdom-cap <%= ENV['PINGDOM_CHECK_NAME'] %> status`
|
10
|
+
Then (erb) the output should contain "Status for Pingdom '<%= ENV['PINGDOM_CHECK_NAME'] %>'"
|
11
|
+
And (erb) the output should contain:
|
12
|
+
"""
|
13
|
+
"name" => "<%= ENV['PINGDOM_CHECK_NAME'] %>"
|
14
|
+
"""
|
15
|
+
|
16
|
+
@slow_process
|
17
|
+
Scenario: Pause check
|
18
|
+
When (erb) I successfully run `pingdom-cap <%= ENV['PINGDOM_CHECK_NAME'] %> pause`
|
19
|
+
Then (erb) the output should contain "Pausing Pingdom '<%= ENV['PINGDOM_CHECK_NAME'] %>'"
|
20
|
+
|
21
|
+
@slow_process
|
22
|
+
Scenario: Unpause check
|
23
|
+
When (erb) I successfully run `pingdom-cap <%= ENV['PINGDOM_CHECK_NAME'] %> unpause`
|
24
|
+
Then (erb) the output should contain "Unpausing Pingdom '<%= ENV['PINGDOM_CHECK_NAME'] %>'"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks
|
6
|
+
body: ''
|
7
|
+
headers:
|
8
|
+
App-Key:
|
9
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- ! '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 09 Feb 2012 18:38:15 GMT
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.14 (Ubuntu)
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.2-1ubuntu4.11
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Req-Limit-Short:
|
30
|
+
- ! 'Remaining: 989 Time until reset: 3539'
|
31
|
+
Req-Limit-Long:
|
32
|
+
- ! 'Remaining: 4789 Time until reset: 86339'
|
33
|
+
Server-Time:
|
34
|
+
- '1328812695'
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Content-Encoding:
|
38
|
+
- gzip
|
39
|
+
Content-Length:
|
40
|
+
- '151'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body: !binary |-
|
46
|
+
H4sIAAAAAAAAA02OMQ6DMAxF7/LnqCJAVMhVqg5R6iioQCLiDAhx9xqxdPDy
|
47
|
+
nr/9D/hI/ltgXwemD2xvtO5HBb+RYxKgu7Ztms6MvcLqFoLFM4QAhZgK/5GH
|
48
|
+
T4vQjUqaK09phTUKvOdrITJnkbMrzCQzXTE5PQy6Nc14G4nmtBa6rfxVKOy4
|
49
|
+
SjvUjPN9/gAt5+/8rwAAAA==
|
50
|
+
http_version: !!null
|
51
|
+
recorded_at: Thu, 09 Feb 2012 18:38:15 GMT
|
52
|
+
- request:
|
53
|
+
method: put
|
54
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks/451149
|
55
|
+
body: paused=true
|
56
|
+
headers:
|
57
|
+
App-Key:
|
58
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
59
|
+
Accept:
|
60
|
+
- ! '*/*'
|
61
|
+
User-Agent:
|
62
|
+
- Ruby
|
63
|
+
response:
|
64
|
+
status:
|
65
|
+
code: 200
|
66
|
+
message: OK
|
67
|
+
headers:
|
68
|
+
Date:
|
69
|
+
- Thu, 09 Feb 2012 18:38:15 GMT
|
70
|
+
Server:
|
71
|
+
- Apache/2.2.14 (Ubuntu)
|
72
|
+
X-Powered-By:
|
73
|
+
- PHP/5.3.2-1ubuntu4.11
|
74
|
+
Cache-Control:
|
75
|
+
- no-cache
|
76
|
+
Req-Limit-Short:
|
77
|
+
- ! 'Remaining: 988 Time until reset: 3539'
|
78
|
+
Req-Limit-Long:
|
79
|
+
- ! 'Remaining: 4788 Time until reset: 86339'
|
80
|
+
Server-Time:
|
81
|
+
- '1328812695'
|
82
|
+
Vary:
|
83
|
+
- Accept-Encoding
|
84
|
+
Content-Length:
|
85
|
+
- '51'
|
86
|
+
Connection:
|
87
|
+
- close
|
88
|
+
Content-Type:
|
89
|
+
- application/json; charset=utf-8
|
90
|
+
body: ! '{"message":"Modification of check was successful!"}'
|
91
|
+
http_version: !!null
|
92
|
+
recorded_at: Thu, 09 Feb 2012 18:38:16 GMT
|
93
|
+
recorded_with: VCR 2.0.0.rc1
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks
|
6
|
+
body: ''
|
7
|
+
headers:
|
8
|
+
App-Key:
|
9
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- ! '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 09 Feb 2012 18:38:12 GMT
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.14 (Ubuntu)
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.2-1ubuntu4.11
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Req-Limit-Short:
|
30
|
+
- ! 'Remaining: 991 Time until reset: 3542'
|
31
|
+
Req-Limit-Long:
|
32
|
+
- ! 'Remaining: 4791 Time until reset: 86342'
|
33
|
+
Server-Time:
|
34
|
+
- '1328812694'
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Content-Encoding:
|
38
|
+
- gzip
|
39
|
+
Content-Length:
|
40
|
+
- '151'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body: !binary |-
|
46
|
+
H4sIAAAAAAAAA02OMQ6DMAxF7/LnqCJAVMhVqg5R6iioQCLiDAhx9xqxdPDy
|
47
|
+
nr/9D/hI/ltgXwemD2xvtO5HBb+RYxKgu7Ztms6MvcLqFoLFM4QAhZgK/5GH
|
48
|
+
T4vQjUqaK09phTUKvOdrITJnkbMrzCQzXTE5PQy6Nc14G4nmtBa6rfxVKOy4
|
49
|
+
SjvUjPN9/gAt5+/8rwAAAA==
|
50
|
+
http_version: !!null
|
51
|
+
recorded_at: Thu, 09 Feb 2012 18:38:14 GMT
|
52
|
+
- request:
|
53
|
+
method: get
|
54
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks/451149
|
55
|
+
body: ''
|
56
|
+
headers:
|
57
|
+
App-Key:
|
58
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
59
|
+
Accept-Encoding:
|
60
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
61
|
+
Accept:
|
62
|
+
- ! '*/*'
|
63
|
+
User-Agent:
|
64
|
+
- Ruby
|
65
|
+
response:
|
66
|
+
status:
|
67
|
+
code: 200
|
68
|
+
message: OK
|
69
|
+
headers:
|
70
|
+
Date:
|
71
|
+
- Thu, 09 Feb 2012 18:38:14 GMT
|
72
|
+
Server:
|
73
|
+
- Apache/2.2.14 (Ubuntu)
|
74
|
+
X-Powered-By:
|
75
|
+
- PHP/5.3.2-1ubuntu4.11
|
76
|
+
Cache-Control:
|
77
|
+
- no-cache
|
78
|
+
Req-Limit-Short:
|
79
|
+
- ! 'Remaining: 990 Time until reset: 3540'
|
80
|
+
Req-Limit-Long:
|
81
|
+
- ! 'Remaining: 4790 Time until reset: 86340'
|
82
|
+
Server-Time:
|
83
|
+
- '1328812694'
|
84
|
+
Vary:
|
85
|
+
- Accept-Encoding
|
86
|
+
Content-Encoding:
|
87
|
+
- gzip
|
88
|
+
Content-Length:
|
89
|
+
- '320'
|
90
|
+
Connection:
|
91
|
+
- close
|
92
|
+
Content-Type:
|
93
|
+
- application/json; charset=utf-8
|
94
|
+
body: !binary |-
|
95
|
+
H4sIAAAAAAAAA12RwW6DMAyG38WnTWKFUOja3PYGu+w0JpQGU6JCkiVmqKp4
|
96
|
+
9zmqplU9RJG+37H/37mCHlCfQV7BdCCrWojqkIFVE4KE177vIYOA0Y0zGWdB
|
97
|
+
1hlEtB05nJQZQfZqjPjH4hQfCC2GCMMDNX5wFh+gsl1wycQdtY5Mb7RKs5eB
|
98
|
+
gVvYQ8kGk3BRJ2Us/mC43MFUd1T6PHuQFGbupAMqQu4stmVZFNv6UGVAF48p
|
99
|
+
9kDk0z0HTgNNznm9CwRyX6Tk3zNGGlB1GGIq+4gYXt5OaLkC3o09dW7aaDe1
|
100
|
+
R0ctO4nstBWbqn1KjWWTN/myLBv/X9nkz7CuawaDi3S36KTxcO0sKU2m43Gf
|
101
|
+
5U6I7e6Ll0GKZibAqTIYVeSt8jHpNafa70VZF4ebwt/lnY14Uznyuv4CK5ah
|
102
|
+
TOcBAAA=
|
103
|
+
http_version: !!null
|
104
|
+
recorded_at: Thu, 09 Feb 2012 18:38:15 GMT
|
105
|
+
recorded_with: VCR 2.0.0.rc1
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks/451149
|
6
|
+
body: ''
|
7
|
+
headers:
|
8
|
+
App-Key:
|
9
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- ! '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 09 Feb 2012 18:38:16 GMT
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.14 (Ubuntu)
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.2-1ubuntu4.11
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Req-Limit-Short:
|
30
|
+
- ! 'Remaining: 987 Time until reset: 3538'
|
31
|
+
Req-Limit-Long:
|
32
|
+
- ! 'Remaining: 4787 Time until reset: 86338'
|
33
|
+
Server-Time:
|
34
|
+
- '1328812696'
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Content-Encoding:
|
38
|
+
- gzip
|
39
|
+
Content-Length:
|
40
|
+
- '322'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body: !binary |-
|
46
|
+
H4sIAAAAAAAAA12RwW6DMBBE/2VPrUQDJpAmvvUPeumpVMgxS7ACtmsvRVHE
|
47
|
+
v3etqGqUA0J6M9qdWV9BD6jPIK9gOpBVLUR1yMCqCUHCa9/3kEHA6MaZjLMg
|
48
|
+
6wwi2o4cTsqMIHs1RvxjcYoPhBZDhOGBGj84iw9Q2S64FOKOWkemN1ql3cvA
|
49
|
+
wC2coeSASbiokzIWfzBc7mDyHZU+zx4khZkn6YCKkCeLbVkWxbY+VBnQxWOq
|
50
|
+
PRD59J8Dt4Em577eBQK5L1Lz7xkjDag6DDHZPiKGl7cTWnbAu7Gnzk0b7ab2
|
51
|
+
6KjlJJGTtmJTtU9psGzyJl+WZeP/nU3+DOu6ZjC4SHeHThov186S0mQ6XvdZ
|
52
|
+
7oTY7r74GKRoZgJezZGrZDCqyJflz6QJ3Gy/F2VdHG4KP5l3NuJN5drr+gtN
|
53
|
+
FZtp6wEAAA==
|
54
|
+
http_version: !!null
|
55
|
+
recorded_at: Thu, 09 Feb 2012 18:38:16 GMT
|
56
|
+
recorded_with: VCR 2.0.0.rc1
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks/451149
|
6
|
+
body: ''
|
7
|
+
headers:
|
8
|
+
App-Key:
|
9
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- ! '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 09 Feb 2012 18:38:17 GMT
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.14 (Ubuntu)
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.2-1ubuntu4.11
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Req-Limit-Short:
|
30
|
+
- ! 'Remaining: 984 Time until reset: 3537'
|
31
|
+
Req-Limit-Long:
|
32
|
+
- ! 'Remaining: 4784 Time until reset: 86337'
|
33
|
+
Server-Time:
|
34
|
+
- '1328812697'
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Content-Encoding:
|
38
|
+
- gzip
|
39
|
+
Content-Length:
|
40
|
+
- '320'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body: !binary |-
|
46
|
+
H4sIAAAAAAAAA12RwW6DMAyG38WnTWKFUOja3PYGu+w0JpQGU6JCkiVmqKp4
|
47
|
+
9zmqplU9RJG+37H/37mCHlCfQV7BdCCrWojqkIFVE4KE177vIYOA0Y0zGWdB
|
48
|
+
1hlEtB05nJQZQfZqjPjH4hQfCC2GCMMDNX5wFh+gsl1wycQdtY5Mb7RKs5eB
|
49
|
+
gVvYQ8kGk3BRJ2Us/mC43MFUd1T6PHuQFGbupAMqQu4stmVZFNv6UGVAF48p
|
50
|
+
9kDk0z0HTgNNznm9CwRyX6Tk3zNGGlB1GGIq+4gYXt5OaLkC3o09dW7aaDe1
|
51
|
+
R0ctO4nstBWbqn1KjWWTN/myLBv/X9nkz7CuawaDi3S36KTxcO0sKU2m43Gf
|
52
|
+
5U6I7e6Ll0GKZibAqTIYVeSt8jHpNafa70VZF4ebwt/lnY14Uznyuv4CK5ah
|
53
|
+
TOcBAAA=
|
54
|
+
http_version: !!null
|
55
|
+
recorded_at: Thu, 09 Feb 2012 18:38:18 GMT
|
56
|
+
recorded_with: VCR 2.0.0.rc1
|
@@ -0,0 +1,93 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks
|
6
|
+
body: ''
|
7
|
+
headers:
|
8
|
+
App-Key:
|
9
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- ! '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Thu, 09 Feb 2012 18:38:16 GMT
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.14 (Ubuntu)
|
25
|
+
X-Powered-By:
|
26
|
+
- PHP/5.3.2-1ubuntu4.11
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Req-Limit-Short:
|
30
|
+
- ! 'Remaining: 986 Time until reset: 3538'
|
31
|
+
Req-Limit-Long:
|
32
|
+
- ! 'Remaining: 4786 Time until reset: 86338'
|
33
|
+
Server-Time:
|
34
|
+
- '1328812697'
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Content-Encoding:
|
38
|
+
- gzip
|
39
|
+
Content-Length:
|
40
|
+
- '153'
|
41
|
+
Connection:
|
42
|
+
- close
|
43
|
+
Content-Type:
|
44
|
+
- application/json; charset=utf-8
|
45
|
+
body: !binary |-
|
46
|
+
H4sIAAAAAAAAA02OMQ6DMAxF7/LnqCJAVMhVqg5RagQqkAg7A0LcvUYsHby8
|
47
|
+
52//A3Gk+GX414HpA986a9veIG4UhBTYpq6rqnF9a7CGheDxHIYBBmNi+SOP
|
48
|
+
mBalG3Gai0xphXcGsudrYRTJKufAIqQzXTE93XW2dlV/G43mtDLdVv8asAQp
|
49
|
+
2g45FNY65/v8ASfheBKzAAAA
|
50
|
+
http_version: !!null
|
51
|
+
recorded_at: Thu, 09 Feb 2012 18:38:17 GMT
|
52
|
+
- request:
|
53
|
+
method: put
|
54
|
+
uri: https://john%40example.com:zzzzyyyyxxxxwwww@api.pingdom.com/api/2.0/checks/451149
|
55
|
+
body: paused=false
|
56
|
+
headers:
|
57
|
+
App-Key:
|
58
|
+
- aaaabbbbccccddddeeeefffffaaaabbbb
|
59
|
+
Accept:
|
60
|
+
- ! '*/*'
|
61
|
+
User-Agent:
|
62
|
+
- Ruby
|
63
|
+
response:
|
64
|
+
status:
|
65
|
+
code: 200
|
66
|
+
message: OK
|
67
|
+
headers:
|
68
|
+
Date:
|
69
|
+
- Thu, 09 Feb 2012 18:38:17 GMT
|
70
|
+
Server:
|
71
|
+
- Apache/2.2.14 (Ubuntu)
|
72
|
+
X-Powered-By:
|
73
|
+
- PHP/5.3.2-1ubuntu4.11
|
74
|
+
Cache-Control:
|
75
|
+
- no-cache
|
76
|
+
Req-Limit-Short:
|
77
|
+
- ! 'Remaining: 985 Time until reset: 3537'
|
78
|
+
Req-Limit-Long:
|
79
|
+
- ! 'Remaining: 4785 Time until reset: 86337'
|
80
|
+
Server-Time:
|
81
|
+
- '1328812697'
|
82
|
+
Vary:
|
83
|
+
- Accept-Encoding
|
84
|
+
Content-Length:
|
85
|
+
- '51'
|
86
|
+
Connection:
|
87
|
+
- close
|
88
|
+
Content-Type:
|
89
|
+
- application/json; charset=utf-8
|
90
|
+
body: ! '{"message":"Modification of check was successful!"}'
|
91
|
+
http_version: !!null
|
92
|
+
recorded_at: Thu, 09 Feb 2012 18:38:17 GMT
|
93
|
+
recorded_with: VCR 2.0.0.rc1
|
data/lib/pingdom_cap.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module PingdomCap
|
2
|
+
class App
|
3
|
+
def initialize
|
4
|
+
end
|
5
|
+
def run
|
6
|
+
username = ENV['PINGDOM_USERNAME']
|
7
|
+
password = ENV['PINGDOM_PASSWORD']
|
8
|
+
key = ENV['PINGDOM_KEY']
|
9
|
+
check_name = ARGV[0]
|
10
|
+
operation = ARGV[1] || 'status'
|
11
|
+
|
12
|
+
if check_name
|
13
|
+
pingdom = PingdomCap::Client.new(username: username, password: password, key: key)
|
14
|
+
pingdom.send(operation, check_name)
|
15
|
+
else
|
16
|
+
puts "usage: pingdom-cap check-name [status | pause | unpause]"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
module PingdomCap
|
4
|
+
module Capistrano
|
5
|
+
|
6
|
+
def self.load_into(configuration)
|
7
|
+
configuration.load do
|
8
|
+
namespace :pingdom do
|
9
|
+
|
10
|
+
def param(name)
|
11
|
+
ENV[name.to_s.upcase] || fetch(name)
|
12
|
+
end
|
13
|
+
def pingdom(configuration, operation)
|
14
|
+
check_name = param(:pingdom_check_name)
|
15
|
+
username = param(:pingdom_username)
|
16
|
+
password = param(:pingdom_password)
|
17
|
+
key = param(:pingdom_key)
|
18
|
+
if configuration.dry_run
|
19
|
+
logger.info "DRY RUN: pingdom_cap #{check_name} #{operation} not actually run."
|
20
|
+
else
|
21
|
+
client = PingdomCap::Client.new(username: username, password: password, key: key)
|
22
|
+
client.send(operation, check_name)
|
23
|
+
end
|
24
|
+
logger.info("Pingdom: #{operation}")
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Status of check at Pingdom"
|
28
|
+
task :status, :except => { :no_release => true } do
|
29
|
+
pingdom(configuration, 'status')
|
30
|
+
end
|
31
|
+
desc "Pause checks at Pingdom"
|
32
|
+
task :pause, :except => { :no_release => true } do
|
33
|
+
pingdom(configuration, 'pause')
|
34
|
+
end
|
35
|
+
desc "Unpause checks at Pingdom"
|
36
|
+
task :unpause, :except => { :no_release => true } do
|
37
|
+
pingdom(configuration, 'unpause')
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if Capistrano::Configuration.instance
|
47
|
+
PingdomCap::Capistrano.load_into(Capistrano::Configuration.instance)
|
48
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'awesome_print'
|
4
|
+
|
5
|
+
module PingdomCap
|
6
|
+
class Client
|
7
|
+
BASE_SERVER_ADDRESS = "https://api.pingdom.com/api/2.0"
|
8
|
+
OPTIONS = {
|
9
|
+
url: BASE_SERVER_ADDRESS
|
10
|
+
}
|
11
|
+
REQUIRED_OPTIONS = [ :key, :url, :username, :password ]
|
12
|
+
|
13
|
+
attr_reader :connection
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
options = OPTIONS.merge(options)
|
17
|
+
raise "Options #{REQUIRED_OPTIONS.join(', ')} are required" if REQUIRED_OPTIONS.any? { |op| options[op].nil? }
|
18
|
+
headers = { 'App-Key' => options[:key] }
|
19
|
+
@connection = Faraday::Connection.new(url: options[:url], headers: headers) do |builder|
|
20
|
+
builder.response :logger if options[:logger]
|
21
|
+
builder.adapter Faraday.default_adapter
|
22
|
+
builder.request :url_encoded
|
23
|
+
builder.use Faraday::Response::Mashify
|
24
|
+
builder.use Faraday::Response::ParseJson
|
25
|
+
end
|
26
|
+
@connection.basic_auth(options[:username], options[:password])
|
27
|
+
end
|
28
|
+
|
29
|
+
def status(name)
|
30
|
+
puts "Status for Pingdom '#{name}'"
|
31
|
+
ap get_detailed_check_information(name_to_checkid(name)).to_hash, plain: true
|
32
|
+
end
|
33
|
+
|
34
|
+
def pause(name)
|
35
|
+
puts "Pausing Pingdom '#{name}'"
|
36
|
+
check_pause(name_to_checkid(name))
|
37
|
+
end
|
38
|
+
|
39
|
+
def unpause(name)
|
40
|
+
puts "Unpausing Pingdom '#{name}'"
|
41
|
+
check_unpause(name_to_checkid(name))
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def check_pause(checkid)
|
47
|
+
modify_check(checkid, { paused: true })
|
48
|
+
end
|
49
|
+
|
50
|
+
def check_unpause(checkid)
|
51
|
+
modify_check(checkid, { paused: false })
|
52
|
+
end
|
53
|
+
|
54
|
+
def name_to_checkid(name)
|
55
|
+
unless @name_to_checkid
|
56
|
+
@name_to_checkid = {}
|
57
|
+
response = get_check_list.body
|
58
|
+
response['checks'].each { |m| @name_to_checkid[m.name] = m.id }
|
59
|
+
end
|
60
|
+
raise "There is no check for '#{name}'" unless @name_to_checkid[name]
|
61
|
+
@name_to_checkid[name]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Since these methods are functional and don't do REST, the names come from the API docs
|
65
|
+
|
66
|
+
def get_detailed_check_information(checkid)
|
67
|
+
# http://www.pingdom.com/services/api-documentation-rest/#MethodGet+Detailed+Check+Information
|
68
|
+
connection.get("checks/#{checkid}").body.check
|
69
|
+
end
|
70
|
+
|
71
|
+
def modify_check(checkid, params)
|
72
|
+
# http://www.pingdom.com/services/api-documentation-rest/#MethodModify+Check
|
73
|
+
response = connection.put("checks/#{checkid}") do |req|
|
74
|
+
# Next line shouldn't be necessary; apparently url_encoded only triggers for POST
|
75
|
+
req.body = Faraday::Utils.build_nested_query params
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_check_list
|
80
|
+
# http://www.pingdom.com/services/api-documentation-rest/#MethodGet+Check+List
|
81
|
+
connection.get('checks')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/pingdom-cap.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'pingdom_cap/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'pingdom-cap'
|
7
|
+
s.version = PingdomCap::VERSION
|
8
|
+
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
9
|
+
s.summary = 'Pause/unpause a Pingdom service from Capistrano'
|
10
|
+
s.description = 'Pause/unpause a Pingdom service from Capistrano'
|
11
|
+
s.authors = ['Iora Health']
|
12
|
+
s.email = 'rubygems@iorahealth.com'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.homepage = 'https://github.com/IoraHealth/pingdom-cap'
|
15
|
+
s.rdoc_options = ['--charset=UTF-8']
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
|
20
|
+
s.add_dependency 'awesome_print', '~> 1.0.2'
|
21
|
+
s.add_dependency 'capistrano', '~> 2.9.0'
|
22
|
+
s.add_dependency 'faraday', [ '>= 0.7.5', '< 0.8' ]
|
23
|
+
s.add_dependency 'faraday_middleware', [ '>= 0.7', '< 0.8' ]
|
24
|
+
s.add_dependency 'hashie', '~> 1.2.0'
|
25
|
+
s.add_dependency 'multi_json', '~> 1.0.4'
|
26
|
+
|
27
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
28
|
+
s.add_development_dependency 'rspec', '~> 2.8.0'
|
29
|
+
s.add_development_dependency 'mocha', '~> 0.10.0'
|
30
|
+
s.add_development_dependency 'webmock', '~> 1.7.10'
|
31
|
+
s.add_development_dependency 'cucumber', '~> 1.1.4'
|
32
|
+
s.add_development_dependency 'aruba', '~> 0.4.11'
|
33
|
+
s.add_development_dependency 'vcr', '= 2.0.0.rc1'
|
34
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PingdomCap::Capistrano do
|
4
|
+
subject { PingdomCap::Capistrano }
|
5
|
+
let(:io) { StringIO.new }
|
6
|
+
let(:configuration) do
|
7
|
+
Capistrano::Configuration.new.tap do |config|
|
8
|
+
config.dry_run = true
|
9
|
+
config.set(:pingdom_check_name, ENV['PINGDOM_CHECK_NAME'])
|
10
|
+
config.set(:pingdom_username, ENV['PINGDOM_USERNAME'])
|
11
|
+
config.set(:pingdom_password, ENV['PINGDOM_PASSWORD'])
|
12
|
+
config.set(:pingdom_key, ENV['PINGDOM_KEY'])
|
13
|
+
logger = Capistrano::Logger.new(:output => io)
|
14
|
+
logger.level = Capistrano::Logger::MAX_LEVEL
|
15
|
+
config.logger = logger
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
subject.load_into(configuration)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should define pingdom:status" do
|
24
|
+
configuration.find_task('pingdom:status').should_not be_nil
|
25
|
+
end
|
26
|
+
it "should define pingdom:pause" do
|
27
|
+
configuration.find_task('pingdom:pause').should_not be_nil
|
28
|
+
end
|
29
|
+
it "should define pingdom:unpause" do
|
30
|
+
configuration.find_task('pingdom:unpause').should_not be_nil
|
31
|
+
end
|
32
|
+
it "should display status when calling pingdom:status" do
|
33
|
+
configuration.find_and_execute_task('pingdom:status')
|
34
|
+
io.string.include?('** Pingdom: status').should be_true
|
35
|
+
end
|
36
|
+
it "should log when calling pingdom:pause" do
|
37
|
+
configuration.find_and_execute_task('pingdom:pause')
|
38
|
+
io.string.include?('** Pingdom: pause').should be_true
|
39
|
+
end
|
40
|
+
it "should log when calling pingdom:pause" do
|
41
|
+
configuration.find_and_execute_task('pingdom:unpause')
|
42
|
+
io.string.include?('** Pingdom: unpause').should be_true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PingdomCap::Client, '.new' do
|
4
|
+
subject { PingdomCap::Client }
|
5
|
+
it "should raise an error unless a key is specified" do
|
6
|
+
lambda { subject.new(key: nil) }.should raise_error
|
7
|
+
end
|
8
|
+
it "should raise an error unless a url is specified" do
|
9
|
+
lambda { subject.new(url: nil) }.should raise_error
|
10
|
+
end
|
11
|
+
it "should raise an error unless a username is specified" do
|
12
|
+
lambda { subject.new(username: nil) }.should raise_error
|
13
|
+
end
|
14
|
+
it "should raise an error unless a password is specified" do
|
15
|
+
lambda { subject.new(password: nil) }.should raise_error
|
16
|
+
end
|
17
|
+
it "should not raise an error when key, url, username, and password are specified" do
|
18
|
+
lambda { subject.new(key: 'some_key', url: 'https://api.pingdom.com', username: 'john@example.com', password: '123456') }.should_not raise_error
|
19
|
+
end
|
20
|
+
it "should not raise an error when non-default options are missing" do
|
21
|
+
lambda { subject.new(key: 'some_key', username: 'john@example.com', password: '123456') }.should_not raise_error
|
22
|
+
end
|
23
|
+
it "should create a connection during initialization" do
|
24
|
+
client = subject.new(key: 'some_key', username: 'john@example.com', password: '123456')
|
25
|
+
client.connection.should_not be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe PingdomCap::Client do
|
30
|
+
subject { PingdomCap::Client.new(
|
31
|
+
username: ENV['PINGDOM_USERNAME'] || 'john@example.com',
|
32
|
+
password: ENV['PINGDOM_PASSWORD'] || 'zzzzyyyyxxxxwwww',
|
33
|
+
key: ENV['PINGDOM_KEY'] || 'aaaabbbbccccddddeeeefffffaaaabbbb'
|
34
|
+
) }
|
35
|
+
let(:check_name) { ENV['PINGDOM_CHECK_NAME'] || '7fff' }
|
36
|
+
let(:any_status) { /\"status\" => \"(?:unknown|up|paused)\"/m }
|
37
|
+
let(:unpaused) { /\"status\" => \"(?:unknown|up)\"/m }
|
38
|
+
let(:paused) { /\"status\" => \"paused\"/m }
|
39
|
+
|
40
|
+
describe '#status' do
|
41
|
+
it "should return a status for a check name" do
|
42
|
+
VCR.use_cassette('status') do
|
43
|
+
STDOUT.expects(:puts).with("Status for Pingdom '#{check_name}'")
|
44
|
+
STDOUT.expects(:puts).with(regexp_matches(any_status))
|
45
|
+
subject.status(check_name)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#pause' do
|
51
|
+
it "should be able to pause a check" do
|
52
|
+
VCR.use_cassette('pause') do
|
53
|
+
STDOUT.expects(:puts).with("Pausing Pingdom '#{check_name}'")
|
54
|
+
subject.pause(check_name)
|
55
|
+
end
|
56
|
+
VCR.use_cassette('status_after_pause') do
|
57
|
+
STDOUT.expects(:puts).with("Status for Pingdom '#{check_name}'")
|
58
|
+
STDOUT.expects(:puts).with(regexp_matches(paused))
|
59
|
+
subject.status(check_name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#unpause' do
|
65
|
+
it "should be able to unpause a check" do
|
66
|
+
VCR.use_cassette('unpause') do
|
67
|
+
STDOUT.expects(:puts).with("Unpausing Pingdom '#{check_name}'")
|
68
|
+
subject.unpause(check_name)
|
69
|
+
end
|
70
|
+
VCR.use_cassette('status_after_unpause') do
|
71
|
+
STDOUT.expects(:puts).with("Status for Pingdom '#{check_name}'")
|
72
|
+
STDOUT.expects(:puts).with(regexp_matches(unpaused))
|
73
|
+
subject.status(check_name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ruby-debug'
|
2
|
+
|
3
|
+
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
4
|
+
|
5
|
+
$LOAD_PATH << File.join(PROJECT_ROOT, "lib")
|
6
|
+
|
7
|
+
Bundler.require(:default, :development)
|
8
|
+
|
9
|
+
require 'pingdom_cap'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :mocha
|
13
|
+
end
|
14
|
+
|
15
|
+
# WebMock.disable_net_connect!
|
16
|
+
|
17
|
+
require 'vcr'
|
18
|
+
VCR.configure do |c|
|
19
|
+
c.cassette_library_dir = 'fixtures/cassettes'
|
20
|
+
c.hook_into :webmock
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pingdom-cap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Iora Health
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: awesome_print
|
16
|
+
requirement: &2153844400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2153844400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: capistrano
|
27
|
+
requirement: &2153836900 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.9.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2153836900
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: faraday
|
38
|
+
requirement: &2153832280 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.7.5
|
44
|
+
- - <
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.8'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *2153832280
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: faraday_middleware
|
52
|
+
requirement: &2153819780 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.7'
|
58
|
+
- - <
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.8'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *2153819780
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: hashie
|
66
|
+
requirement: &2153786840 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 1.2.0
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: *2153786840
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: multi_json
|
77
|
+
requirement: &2153777280 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.4
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: *2153777280
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: rake
|
88
|
+
requirement: &2153774380 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.2
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: *2153774380
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: &2153760200 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.8.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: *2153760200
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
name: mocha
|
110
|
+
requirement: &2153746340 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ~>
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.10.0
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: *2153746340
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: webmock
|
121
|
+
requirement: &2153734760 !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ~>
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.7.10
|
127
|
+
type: :development
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: *2153734760
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: cucumber
|
132
|
+
requirement: &2153726980 !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ~>
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 1.1.4
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: *2153726980
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: aruba
|
143
|
+
requirement: &2153703660 !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ~>
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 0.4.11
|
149
|
+
type: :development
|
150
|
+
prerelease: false
|
151
|
+
version_requirements: *2153703660
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: vcr
|
154
|
+
requirement: &2153698720 !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - =
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.0.0.rc1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: *2153698720
|
163
|
+
description: Pause/unpause a Pingdom service from Capistrano
|
164
|
+
email: rubygems@iorahealth.com
|
165
|
+
executables:
|
166
|
+
- pingdom-cap
|
167
|
+
extensions: []
|
168
|
+
extra_rdoc_files: []
|
169
|
+
files:
|
170
|
+
- .gitignore
|
171
|
+
- .rvmrc
|
172
|
+
- Gemfile
|
173
|
+
- LICENSE.txt
|
174
|
+
- README.md
|
175
|
+
- Rakefile
|
176
|
+
- bin/pingdom-cap
|
177
|
+
- features/pingdom-cap_executable.feature
|
178
|
+
- features/step_definitions/erbify_steps.rb
|
179
|
+
- features/support/env.rb
|
180
|
+
- fixtures/cassettes/pause.yml
|
181
|
+
- fixtures/cassettes/status.yml
|
182
|
+
- fixtures/cassettes/status_after_pause.yml
|
183
|
+
- fixtures/cassettes/status_after_unpause.yml
|
184
|
+
- fixtures/cassettes/unpause.yml
|
185
|
+
- lib/pingdom_cap.rb
|
186
|
+
- lib/pingdom_cap/app.rb
|
187
|
+
- lib/pingdom_cap/capistrano.rb
|
188
|
+
- lib/pingdom_cap/client.rb
|
189
|
+
- lib/pingdom_cap/version.rb
|
190
|
+
- pingdom-cap.gemspec
|
191
|
+
- spec/pingdom_cap/capistrano_spec.rb
|
192
|
+
- spec/pingdom_cap/client_spec.rb
|
193
|
+
- spec/spec_helper.rb
|
194
|
+
homepage: https://github.com/IoraHealth/pingdom-cap
|
195
|
+
licenses: []
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options:
|
198
|
+
- --charset=UTF-8
|
199
|
+
require_paths:
|
200
|
+
- lib
|
201
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
segments:
|
208
|
+
- 0
|
209
|
+
hash: -2978655392766651886
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
none: false
|
212
|
+
requirements:
|
213
|
+
- - ! '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
segments:
|
217
|
+
- 0
|
218
|
+
hash: -2978655392766651886
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 1.8.10
|
222
|
+
signing_key:
|
223
|
+
specification_version: 3
|
224
|
+
summary: Pause/unpause a Pingdom service from Capistrano
|
225
|
+
test_files:
|
226
|
+
- features/pingdom-cap_executable.feature
|
227
|
+
- features/step_definitions/erbify_steps.rb
|
228
|
+
- features/support/env.rb
|
229
|
+
- spec/pingdom_cap/capistrano_spec.rb
|
230
|
+
- spec/pingdom_cap/client_spec.rb
|
231
|
+
- spec/spec_helper.rb
|