pingdom-cli 0.1.0 → 0.2.0
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/README.md +10 -0
- data/lib/pingdom/cli/cli.rb +30 -0
- data/lib/pingdom/cli/core.rb +43 -3
- data/lib/pingdom/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ffa63ace83f83dd9b97e1dd159ba7a753f70d41
|
4
|
+
data.tar.gz: 0b16ddc7d7e923543e228472541122220b76f24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07d58bfd20ee1718ca48e8d9b4816beb6ba7293a350333e48dc22dcc007519c933b55c29f331f592487494f9938485472ad0b590c88c77bb1d56337731b6d9bc
|
7
|
+
data.tar.gz: 0823efdca46119122eebfe6f2a4863f9d251b16af724cfe2033f9eb49634e29e2fc1423685b60684bfe31915eabaebe4317fdcbcea70126877714ed32315f350
|
data/README.md
CHANGED
@@ -16,6 +16,16 @@ pingdom simple command line interface
|
|
16
16
|
|
17
17
|
$ pingdom-cli unpause
|
18
18
|
|
19
|
+
## Settings
|
20
|
+
|
21
|
+
create $HOME/.pingdomrc
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
user: 'hogehoge@gmail.com'
|
25
|
+
password: 'hogehoge'
|
26
|
+
app_key: '123456hogehogehogehogehogehogehogehogehogehoge'
|
27
|
+
```
|
28
|
+
|
19
29
|
## Installation
|
20
30
|
|
21
31
|
Add this line to your application's Gemfile:
|
data/lib/pingdom/cli/cli.rb
CHANGED
@@ -27,6 +27,36 @@ module Pingdom
|
|
27
27
|
puts @core.checks.to_json
|
28
28
|
end
|
29
29
|
|
30
|
+
desc "actions", "actions"
|
31
|
+
def actions
|
32
|
+
puts @core.actions.to_json
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "contacts", "contacts"
|
36
|
+
def contacts
|
37
|
+
puts @core.contacts.to_json
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "probes", "probes"
|
41
|
+
def probes
|
42
|
+
puts @core.probes.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "reference", "reference"
|
46
|
+
def reference
|
47
|
+
puts @core.reference.to_json
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "reports_public", "reports_public"
|
51
|
+
def reports_public
|
52
|
+
puts @core.reports_public.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "settings", "settings"
|
56
|
+
def settings
|
57
|
+
puts @core.settings.to_json
|
58
|
+
end
|
59
|
+
|
30
60
|
desc "pause", "pause"
|
31
61
|
def pause
|
32
62
|
puts @core.update({ paused: true })
|
data/lib/pingdom/cli/core.rb
CHANGED
@@ -7,20 +7,60 @@ module Pingdom
|
|
7
7
|
|
8
8
|
def initialize(config)
|
9
9
|
@config = config
|
10
|
-
@
|
10
|
+
@url_base = "https://#{CGI::escape @config['user']}:#{CGI::escape @config['password']}@api.pingdom.com/api/2.0/"
|
11
11
|
@header = {"App-Key" => @config['app_key']}
|
12
12
|
end
|
13
13
|
|
14
14
|
def checks
|
15
|
-
response = RestClient.get(
|
15
|
+
response = RestClient.get(get_url('checks'), @header)
|
16
|
+
results = JSON.parse(response.body, :symbolize_names => true)
|
17
|
+
results[:checks].each do |result|
|
18
|
+
result[:lasttesttime] = Time.at(result[:lasttesttime]) unless result[:lasttesttime].nil?
|
19
|
+
result[:lasterrortime] = Time.at(result[:lasterrortime]) unless result[:lasterrortime].nil?
|
20
|
+
result[:created] = Time.at(result[:created]) unless result[:created].nil?
|
21
|
+
end
|
22
|
+
results
|
23
|
+
end
|
24
|
+
|
25
|
+
def actions
|
26
|
+
response = RestClient.get(get_url('actions'), @header)
|
27
|
+
JSON.parse(response.body, :symbolize_names => true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def contacts
|
31
|
+
response = RestClient.get(get_url('contacts'), @header)
|
32
|
+
JSON.parse(response.body, :symbolize_names => true)
|
33
|
+
end
|
34
|
+
|
35
|
+
def probes
|
36
|
+
response = RestClient.get(get_url('probes'), @header)
|
37
|
+
JSON.parse(response.body, :symbolize_names => true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def reference
|
41
|
+
response = RestClient.get(get_url('reference'), @header)
|
42
|
+
JSON.parse(response.body, :symbolize_names => true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def reports_public
|
46
|
+
response = RestClient.get(get_url('reports.public'), @header)
|
47
|
+
JSON.parse(response.body, :symbolize_names => true)
|
48
|
+
end
|
49
|
+
|
50
|
+
def settings
|
51
|
+
response = RestClient.get(get_url('settings'), @header)
|
16
52
|
JSON.parse(response.body, :symbolize_names => true)
|
17
53
|
end
|
18
54
|
|
19
55
|
def update(params)
|
20
|
-
response = RestClient.put(
|
56
|
+
response = RestClient.put(get_url('checks'), params, @header)
|
21
57
|
response.body
|
22
58
|
end
|
23
59
|
|
60
|
+
private
|
61
|
+
def get_url(action)
|
62
|
+
@url_base + action
|
63
|
+
end
|
24
64
|
end
|
25
65
|
end
|
26
66
|
end
|
data/lib/pingdom/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingdom-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Toyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|