copperegg 0.5.2 → 0.5.3
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.
- data/Gemfile.lock +3 -1
- data/copperegg-0.5.2.1.gem +0 -0
- data/copperegg-0.5.2.gem +0 -0
- data/copperegg-0.5.3.pre.gem +0 -0
- data/copperegg-0.5.3.pre2.gem +0 -0
- data/lib/copperegg/metrics.rb +23 -3
- data/lib/copperegg/util.rb +23 -5
- data/lib/copperegg/ver.rb +1 -1
- metadata +5 -2
data/Gemfile.lock
CHANGED
Binary file
|
data/copperegg-0.5.2.gem
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/lib/copperegg/metrics.rb
CHANGED
@@ -23,8 +23,26 @@ module CopperEgg
|
|
23
23
|
return
|
24
24
|
end
|
25
25
|
|
26
|
-
def samples(
|
27
|
-
|
26
|
+
def samples(group_name, metricname, starttime=nil, duration=nil, sample_size=nil)
|
27
|
+
return if group_name.nil?
|
28
|
+
return if metricname.nil?
|
29
|
+
|
30
|
+
metric_name = []
|
31
|
+
metrics = {}
|
32
|
+
metric_gid = []
|
33
|
+
query = {}
|
34
|
+
params = {}
|
35
|
+
|
36
|
+
metric_name = [metricname]
|
37
|
+
metrics["metrics"] = metric_name
|
38
|
+
metric_gid = [metrics]
|
39
|
+
query[group_name] = metric_gid
|
40
|
+
params["queries"] = query
|
41
|
+
params["starttime"] = starttime if !starttime.nil?
|
42
|
+
params["duration"] = duration if !duration.nil?
|
43
|
+
params["sample_size"] = sample_size if !sample_size.nil?
|
44
|
+
|
45
|
+
samples = @util.make_api_get_request("/samples.json", @apikey, params)
|
28
46
|
return samples
|
29
47
|
end
|
30
48
|
|
@@ -58,7 +76,9 @@ module CopperEgg
|
|
58
76
|
dashes = @util.make_api_get_request("/dashboards.json", @apikey, nil)
|
59
77
|
return nil if dashes.nil?
|
60
78
|
|
61
|
-
dashboards = JSON.parse(dashes.body)
|
79
|
+
# dashboards = JSON.parse(dashes.body)
|
80
|
+
# modified 12-10-2012 ... get returns the body
|
81
|
+
dashboards = JSON.parse(dashes)
|
62
82
|
dashboards.each do |dash|
|
63
83
|
if dash["name"] == dashboard_name
|
64
84
|
return dash
|
data/lib/copperegg/util.rb
CHANGED
@@ -42,20 +42,38 @@ module CopperEgg
|
|
42
42
|
end
|
43
43
|
|
44
44
|
if type == "get"
|
45
|
-
uri.query = URI.encode_www_form(params) if !params.nil?
|
46
45
|
request = Net::HTTP::Get.new(uri.request_uri)
|
46
|
+
request.body = MultiJson.dump(params)
|
47
47
|
else
|
48
48
|
request = Net::HTTP::Post.new(uri.request_uri)
|
49
49
|
request.body = MultiJson.dump(params)
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
request.basic_auth(apikey, "U")
|
53
53
|
request["Content-Type"] = "application/json"
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
connect_try_count = 0
|
56
|
+
response = nil
|
57
|
+
begin
|
58
|
+
response = http.request(request)
|
59
|
+
rescue Exception => e
|
60
|
+
connect_try_count += 1
|
61
|
+
if connect_try_count > 1
|
62
|
+
log "#{e.inspect}"
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
sleep 0.5
|
66
|
+
retry
|
67
|
+
end
|
68
|
+
|
69
|
+
if response == nil || response.code != "200"
|
56
70
|
return nil
|
57
71
|
end
|
58
|
-
|
72
|
+
if type == "get"
|
73
|
+
return response.body
|
74
|
+
else
|
75
|
+
return response
|
76
|
+
end
|
59
77
|
end
|
60
78
|
|
61
79
|
end
|
data/lib/copperegg/ver.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copperegg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -38,7 +38,10 @@ files:
|
|
38
38
|
- ./LICENSE
|
39
39
|
- ./README.md
|
40
40
|
- ./Rakefile
|
41
|
+
- ./copperegg-0.5.2.1.gem
|
41
42
|
- ./copperegg-0.5.2.gem
|
43
|
+
- ./copperegg-0.5.3.pre.gem
|
44
|
+
- ./copperegg-0.5.3.pre2.gem
|
42
45
|
- ./copperegg.gemspec
|
43
46
|
- ./examples/example.rb
|
44
47
|
- ./lib/copperegg/metrics.rb
|