scout_api 0.9.1 → 1.0.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.
- data/CHANGELOG +5 -1
- data/README.rdoc +7 -3
- data/lib/scout_api/account.rb +5 -2
- data/lib/scout_api/group.rb +32 -15
- data/lib/scout_api/metric.rb +16 -16
- data/lib/scout_api/metric_proxy.rb +11 -7
- data/lib/scout_api/plugin.rb +27 -10
- data/lib/scout_api/server.rb +47 -24
- data/lib/scout_api/version.rb +1 -1
- data/scout_api.gemspec +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
|
@@ -18,9 +18,9 @@ Require the gem and authenticate to get your Scout on:
|
|
|
18
18
|
|
|
19
19
|
You can query for the following high-level objects:
|
|
20
20
|
|
|
21
|
-
* Scout::Server
|
|
22
|
-
* Scout::Group
|
|
23
|
-
* Scout::Metric
|
|
21
|
+
* {Scout::Server}
|
|
22
|
+
* {Scout::Group}
|
|
23
|
+
* {Scout::Metric}
|
|
24
24
|
|
|
25
25
|
Each of the classes have Rails-like finder methods. For example:
|
|
26
26
|
|
|
@@ -66,6 +66,10 @@ Create and delete servers:
|
|
|
66
66
|
# delete the server with id=10
|
|
67
67
|
Scout::Server.delete(10)
|
|
68
68
|
|
|
69
|
+
== Ruby Compatibility
|
|
70
|
+
|
|
71
|
+
scout_api has been tested against Ruby 1.8.6, Ruby 1.8.7, and Ruby 1.9.2.
|
|
72
|
+
|
|
69
73
|
== Note on Patches/Pull Requests
|
|
70
74
|
|
|
71
75
|
* Fork the project[https://github.com/highgroove/scout-api].
|
data/lib/scout_api/account.rb
CHANGED
|
@@ -13,7 +13,7 @@ class Scout::Account
|
|
|
13
13
|
|
|
14
14
|
# Recent alerts across all servers on this account
|
|
15
15
|
#
|
|
16
|
-
# @return [Array] An array of Scout::Alert objects
|
|
16
|
+
# @return [Array] An array of {Scout::Alert} objects
|
|
17
17
|
def alerts
|
|
18
18
|
response = self.class.get("/activities.xml")
|
|
19
19
|
response['alerts'] ? response['alerts'].map { |alert| Scout::Alert.new(alert) } : Array.new
|
|
@@ -48,10 +48,13 @@ class Scout::Account
|
|
|
48
48
|
alias_method :http_get, :get
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
# Wraps GET requests with error handling, attaches to the authenticated account, and
|
|
52
|
+
# adds the library version as a parameter.
|
|
53
|
+
#
|
|
51
54
|
# Checks for errors via the HTTP status code. If an error is found, a
|
|
52
55
|
# Scout::Error is raised. Otherwise, the response.
|
|
53
56
|
#
|
|
54
|
-
# @return HTTParty::Response
|
|
57
|
+
# @return [HTTParty::Response]
|
|
55
58
|
def self.get(uri)
|
|
56
59
|
raise Scout::Error,
|
|
57
60
|
"Authentication is required (scout = Scout::Account.new('youraccountname', 'your@awesome.com', 'sekret'))" if param.nil?
|
data/lib/scout_api/group.rb
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
# Groups represent a collection of servers.
|
|
2
2
|
# They can be created in the Scout UI to put similar servers together (ex: Web Servers, Database Servers).
|
|
3
3
|
class Scout::Group < Hashie::Mash
|
|
4
|
-
# Retrieve metric information. See Scout::Metric
|
|
4
|
+
# Retrieve metric information. See {Scout::Metric.average} for a list of options for the calculation
|
|
5
5
|
# methods (average, minimum, maximum).
|
|
6
6
|
#
|
|
7
7
|
# Examples:
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
9
|
+
# # All metrics associated with this group.
|
|
10
|
+
# Scout::Group.metrics
|
|
11
|
+
#
|
|
12
|
+
# # Metrics with name =~ 'Memory Used' across all servers in this group.
|
|
13
|
+
# Scout::Group.metrics.all(:name => 'Memory Used')
|
|
14
|
+
#
|
|
15
|
+
# # Average value of metrics with name =~ 'Memory Used' across all servers in the group
|
|
16
|
+
# Scout::Group.metrics.average(:name => 'Memory Used')
|
|
17
|
+
#
|
|
18
|
+
# # Maximum value ...
|
|
19
|
+
# Scout::Group.metrics.maximum(:name => 'Memory Used')
|
|
20
|
+
#
|
|
21
|
+
# # Minimum value ...
|
|
22
|
+
# Scout::Group.metrics.minimum(:name => 'Memory Used')
|
|
23
|
+
#
|
|
24
|
+
# # Sum metrics, then take average
|
|
25
|
+
# Scout::Group.metrics.average(:name => 'request_rate', :aggregate => true)
|
|
26
|
+
#
|
|
27
|
+
# # Retrieve data starting @ 5 hours ago ending at 2 hours ago
|
|
28
|
+
# Scout::Group.metrics.average(:name => 'request_rate', :start => Time.now.utc-5*3600, :end => Time.now.utc-2*3600)
|
|
29
|
+
#
|
|
30
|
+
# # An array of time series values over the past hour
|
|
31
|
+
# Scout::Group.metrics.average(:name => 'Memory Used').to_array
|
|
32
|
+
#
|
|
33
|
+
# # A Url to a Google Sparkline Chart
|
|
34
|
+
# Scout::Group.metrics.average(:name => 'Memory Used').to_sparkline
|
|
18
35
|
attr_reader :metrics
|
|
19
36
|
|
|
20
37
|
def initialize(hash) #:nodoc:
|
|
@@ -24,9 +41,9 @@ class Scout::Group < Hashie::Mash
|
|
|
24
41
|
|
|
25
42
|
# Finds the first group that meets the given conditions. Possible parameter formats:
|
|
26
43
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
44
|
+
# Scout::Group.first
|
|
45
|
+
# Scout::Group.first(1)
|
|
46
|
+
# Scout::Group.first(:name => 'db slaves')
|
|
30
47
|
#
|
|
31
48
|
# For the <tt>:name</tt>, a {MySQL-formatted Regex}[http://dev.mysql.com/doc/refman/5.0/en/regexp.html] can be used.
|
|
32
49
|
#
|
|
@@ -53,8 +70,8 @@ class Scout::Group < Hashie::Mash
|
|
|
53
70
|
|
|
54
71
|
# Finds all groups that meets the given conditions. Possible parameter formats:
|
|
55
72
|
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
73
|
+
# Scout::Group.all
|
|
74
|
+
# Scout::Group.all(:name => 'web')
|
|
58
75
|
#
|
|
59
76
|
# For the <tt>:name</tt>, a {MySQL-formatted Regex}[http://dev.mysql.com/doc/refman/5.0/en/regexp.html] can be used.
|
|
60
77
|
#
|
data/lib/scout_api/metric.rb
CHANGED
|
@@ -40,16 +40,17 @@ class Scout::Metric < Hashie::Mash
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
#
|
|
43
|
+
# Finds all metrics that match the conditons specified via <tt>options</tt>. {MetricProxy} uses this method to search for metrics.
|
|
44
|
+
# Refer to {MetricProxy#all} for examples.
|
|
44
45
|
#
|
|
45
|
-
# @return [Array] An array of Scout::Metric objects
|
|
46
|
+
# @return [Array] An array of {Scout::Metric} objects
|
|
46
47
|
def self.all(options = {})
|
|
47
48
|
raise Scout::Error, "A finder condition is required" if options.empty?
|
|
48
49
|
response = Scout::Account.get("/descriptors.xml?name=#{CGI.escape(options[:name].to_s)}&ids=&plugin_ids=#{options[:plugin_ids]}&server_ids=#{options[:server_ids]}&group_ids=#{options[:group_ids]}")
|
|
49
50
|
response['ar_descriptors'] ? response['ar_descriptors'].map { |descriptor| Scout::Metric.new(descriptor) } : Array.new
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
#
|
|
53
|
+
# The average value of a metric by ID or name (ex: <tt>'disk_used'</tt>). If the metric couldn't be found AND/OR
|
|
53
54
|
# hasn't reported since <tt>options[:start]</tt>, a [Scout::Error] is raised.
|
|
54
55
|
#
|
|
55
56
|
# A 3-element Hash is returned with the following keys:
|
|
@@ -93,18 +94,18 @@ class Scout::Metric < Hashie::Mash
|
|
|
93
94
|
calculate('AVG',id_or_name,options)
|
|
94
95
|
end
|
|
95
96
|
|
|
96
|
-
#
|
|
97
|
+
# The maximum value of a metric by ID or name (ex: <tt>'last_minute'</tt>).
|
|
97
98
|
#
|
|
98
|
-
# See
|
|
99
|
+
# Uses the same parameters as {average}. See {average} for options and examples.
|
|
99
100
|
#
|
|
100
101
|
# @return [Hash]
|
|
101
102
|
def self.maximum(id_or_name,options = {})
|
|
102
103
|
calculate('MAX',id_or_name,options)
|
|
103
104
|
end
|
|
104
105
|
|
|
105
|
-
#
|
|
106
|
+
# The minimum value of a metric by ID or name (<tt>ex: 'last_minute'</tt>).
|
|
106
107
|
#
|
|
107
|
-
# See
|
|
108
|
+
# Uses the same parameters as {average}. See {average} for options and examples.
|
|
108
109
|
#
|
|
109
110
|
# @return [Hash]
|
|
110
111
|
def self.minimum(id_or_name,options = {})
|
|
@@ -113,7 +114,7 @@ class Scout::Metric < Hashie::Mash
|
|
|
113
114
|
|
|
114
115
|
# Returns time series data.
|
|
115
116
|
#
|
|
116
|
-
# @return [Array]
|
|
117
|
+
# @return [Array] This is a two-dimensional array. The 1st element is the [Time] in UTC. The 2nd element is the value at that time as a [Float].
|
|
117
118
|
def self.to_array(function,id_or_name,options = {})
|
|
118
119
|
start_time,end_time=format_times(options)
|
|
119
120
|
consolidate,name,ids=series_options(id_or_name,options)
|
|
@@ -132,9 +133,9 @@ class Scout::Metric < Hashie::Mash
|
|
|
132
133
|
#
|
|
133
134
|
# <b>Options:</b>
|
|
134
135
|
#
|
|
135
|
-
# * <tt>:size</tt> - The size of the image in pixels. Default is 200x30
|
|
136
|
-
# * <tt>:line_color</tt> - The color of the line. Default is 0077cc (blue).
|
|
137
|
-
# * <tt>:line_width</tt> - The width of the line in pixels. Default is 2
|
|
136
|
+
# * <tt>:size</tt> - The size of the image in pixels. Default is <tt>'200x30'</tt>.
|
|
137
|
+
# * <tt>:line_color</tt> - The color of the line. Default is <tt>'0077cc'</tt> (blue).
|
|
138
|
+
# * <tt>:line_width</tt> - The width of the line in pixels. Default is <tt>2</t>.
|
|
138
139
|
#
|
|
139
140
|
# @return [String]
|
|
140
141
|
def self.to_sparkline(function,id_or_name,options = {})
|
|
@@ -151,7 +152,7 @@ class Scout::Metric < Hashie::Mash
|
|
|
151
152
|
end
|
|
152
153
|
end
|
|
153
154
|
|
|
154
|
-
# See Scout::Metric#average for a list of options.
|
|
155
|
+
# The average value for this metric. See {Scout::Metric#average} for a list of options.
|
|
155
156
|
#
|
|
156
157
|
# @return [Hash]
|
|
157
158
|
def average(opts = {})
|
|
@@ -160,7 +161,7 @@ class Scout::Metric < Hashie::Mash
|
|
|
160
161
|
end
|
|
161
162
|
alias avg average
|
|
162
163
|
|
|
163
|
-
# See Scout::Metric#average for a list of options.
|
|
164
|
+
# The maximum value for this metric. See {Scout::Metric#average} for a list of options.
|
|
164
165
|
#
|
|
165
166
|
# @return [Hash]
|
|
166
167
|
def maximum(opts = {})
|
|
@@ -169,7 +170,7 @@ class Scout::Metric < Hashie::Mash
|
|
|
169
170
|
end
|
|
170
171
|
alias max maximum
|
|
171
172
|
|
|
172
|
-
# See Scout::Metric#average for a list of options.
|
|
173
|
+
# The minimum value for this metric. See {Scout::Metric#average} for a list of options.
|
|
173
174
|
#
|
|
174
175
|
# @return [Hash]
|
|
175
176
|
def minimum(opts = {})
|
|
@@ -178,8 +179,7 @@ class Scout::Metric < Hashie::Mash
|
|
|
178
179
|
end
|
|
179
180
|
alias min minimum
|
|
180
181
|
|
|
181
|
-
# Metrics are identified by either their given ID or their name.
|
|
182
|
-
# use it.
|
|
182
|
+
# Metrics are identified by either their given ID or their name. Prefers ID.
|
|
183
183
|
def identifier #:nodoc:
|
|
184
184
|
id? ? id : name
|
|
185
185
|
end
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
# See http://stackoverflow.com/questions/1529606/how-do-rails-association-methods-work for background
|
|
4
4
|
#
|
|
5
5
|
# Example usage:
|
|
6
|
-
#
|
|
7
|
-
#
|
|
6
|
+
#
|
|
7
|
+
# # all metrics associated with the group
|
|
8
|
+
# group.metrics
|
|
9
|
+
# # average value of all metrics w/name 'idle' associated with the server
|
|
10
|
+
# server.metrics.average(:name => 'idle')
|
|
8
11
|
class Scout::MetricProxy
|
|
9
12
|
instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$|is\_a\?)/ }
|
|
10
13
|
attr_reader :owner
|
|
@@ -16,9 +19,10 @@ class Scout::MetricProxy
|
|
|
16
19
|
@max_calc = Scout::MetricCalculation.new(self,:MAX)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
# Calculate the average value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner
|
|
22
|
+
# Calculate the average value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner
|
|
23
|
+
# ({Scout::Group}, {Scout::Server}, or {Scout::Plugin}).
|
|
20
24
|
#
|
|
21
|
-
# See Metric#average for options.
|
|
25
|
+
# See {Metric#average} for options.
|
|
22
26
|
#
|
|
23
27
|
# @return [Hash]
|
|
24
28
|
def average(options)
|
|
@@ -28,7 +32,7 @@ class Scout::MetricProxy
|
|
|
28
32
|
end
|
|
29
33
|
alias avg average
|
|
30
34
|
|
|
31
|
-
# Calculate the minimum value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner (Group, Server, or Plugin).
|
|
35
|
+
# Calculate the minimum value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner ({Scout::Group}, {Scout::Server}, or {Scout::Plugin}).
|
|
32
36
|
#
|
|
33
37
|
# See Metric#average for options.
|
|
34
38
|
#
|
|
@@ -40,7 +44,7 @@ class Scout::MetricProxy
|
|
|
40
44
|
end
|
|
41
45
|
alias min minimum
|
|
42
46
|
|
|
43
|
-
# Calculate the maximum value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner (Group, Server, or Plugin).
|
|
47
|
+
# Calculate the maximum value of the metric w/<tt>:name => metric_name</tt> associated with the proxy owner ({Scout::Group}, {Scout::Server}, or {Scout::Plugin}).
|
|
44
48
|
#
|
|
45
49
|
# See Metric#average for options.
|
|
46
50
|
#
|
|
@@ -52,7 +56,7 @@ class Scout::MetricProxy
|
|
|
52
56
|
end
|
|
53
57
|
alias max maximum
|
|
54
58
|
|
|
55
|
-
# Find all metrics w/ <tt>:name => metric_name</tt> associated with the proxy owner (Group, Server, or Plugin).
|
|
59
|
+
# Find all metrics w/ <tt>:name => metric_name</tt> associated with the proxy owner ({Scout::Group}, {Scout::Server}, or {Scout::Plugin}).
|
|
56
60
|
#
|
|
57
61
|
# Example:
|
|
58
62
|
#
|
data/lib/scout_api/plugin.rb
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
class Scout::Plugin < Hashie::Mash
|
|
2
2
|
attr_accessor :server
|
|
3
3
|
|
|
4
|
-
# Retrieve metric information. See Scout::Metric
|
|
4
|
+
# Retrieve metric information. See {Scout::Metric.average} for a list of options for the calculation
|
|
5
5
|
# methods (average, minimum, maximum).
|
|
6
6
|
#
|
|
7
7
|
# Examples:
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
9
|
+
# # All metrics associated with this plugin.
|
|
10
|
+
# Scout::Plugin.metrics
|
|
11
|
+
#
|
|
12
|
+
# # Metrics with name =~ 'Memory Used' on this plugin.
|
|
13
|
+
# Scout::Plugin.metrics.all(:name => 'Memory Used')
|
|
14
|
+
#
|
|
15
|
+
# # Average value of metrics with name =~ 'Memory Used' on this plugin.
|
|
16
|
+
# Scout::Plugin.metrics.average(:name => 'Memory Used')
|
|
17
|
+
#
|
|
18
|
+
# # Maximum value...
|
|
19
|
+
# Scout::Plugin.metrics.maximum(:name => 'Memory Used')
|
|
20
|
+
#
|
|
21
|
+
# # Minumum value...
|
|
22
|
+
# Scout::Plugin.metrics.minimum(:name => 'Memory Used')
|
|
23
|
+
#
|
|
24
|
+
# # Sum metrics, then take average
|
|
25
|
+
# Scout::Plugin.metrics.average(:name => 'request_rate', :aggregate => true)
|
|
26
|
+
#
|
|
27
|
+
# # Retrieve data starting @ 5 hours ago ending at 2 hours ago
|
|
28
|
+
# Scout::Plugin.metrics.average(:name => 'request_rate', :start => Time.now.utc-5*3600, :end => Time.now.utc-2*3600)
|
|
29
|
+
#
|
|
30
|
+
# # An array of time series values over the past hour
|
|
31
|
+
# Scout::Plugin.metrics.average(:name => 'Memory Used').to_array
|
|
32
|
+
#
|
|
33
|
+
# # A Url to a Google Sparkline Chart.
|
|
34
|
+
# Scout::Plugin.metrics.average(:name => 'Memory Used').to_sparkline
|
|
18
35
|
attr_reader :metrics
|
|
19
36
|
|
|
20
37
|
attr_reader :descriptor_hash #:nodoc:
|
data/lib/scout_api/server.rb
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
class Scout::Server < Hashie::Mash
|
|
2
|
-
# Retrieve metric information. See Scout::Metric
|
|
2
|
+
# Retrieve metric information. See {Scout::Metric.average} for a list of options for the calculation
|
|
3
3
|
# methods (average, minimum, maximum).
|
|
4
4
|
#
|
|
5
5
|
# Examples:
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
7
|
+
# # All metrics associated with this server.
|
|
8
|
+
# Scout::Server.metrics
|
|
9
|
+
#
|
|
10
|
+
# # Metrics with name =~ 'Memory Used' on this server.
|
|
11
|
+
# Scout::Server.metrics.all(:name => 'Memory Used')
|
|
12
|
+
#
|
|
13
|
+
# # Average value of metrics with name =~ 'Memory Used' on this server.
|
|
14
|
+
# Scout::Server.metrics.average(:name => 'Memory Used')
|
|
15
|
+
#
|
|
16
|
+
# # Maximum value...
|
|
17
|
+
# Scout::Server.metrics.maximum(:name => 'Memory Used')
|
|
18
|
+
#
|
|
19
|
+
# # Minimum value...
|
|
20
|
+
# Scout::Server.metrics.minimum(:name => 'Memory Used')
|
|
21
|
+
#
|
|
22
|
+
# # Sum metrics, then take average
|
|
23
|
+
# Scout::Server.metrics.average(:name => 'request_rate', :aggregate => true)
|
|
24
|
+
#
|
|
25
|
+
# # Retrieve data starting @ 5 hours ago ending at 2 hours ago
|
|
26
|
+
# Scout::Server.metrics.average(:name => 'request_rate', :start => Time.now.utc-5*3600, :end => Time.now.utc-2*3600)
|
|
27
|
+
#
|
|
28
|
+
# # An array of time series values over the past hour.
|
|
29
|
+
# Scout::Server.metrics.average(:name => 'Memory Used').to_array
|
|
30
|
+
#
|
|
31
|
+
# # A Url to a Google Sparkline Chart.
|
|
32
|
+
# Scout::Server.metrics.average(:name => 'Memory Used').to_sparkline
|
|
16
33
|
attr_reader :metrics
|
|
17
34
|
|
|
18
35
|
def initialize(hash) #:nodoc:
|
|
@@ -24,17 +41,19 @@ class Scout::Server < Hashie::Mash
|
|
|
24
41
|
super(hash)
|
|
25
42
|
end
|
|
26
43
|
|
|
44
|
+
# Returns the key identifier for this server (ex: '<tt>6ecad322-0d17-4cb8-9b2c-a12c4541853f</tt>').
|
|
45
|
+
#
|
|
27
46
|
# Ruby 1.9.2 Hash#key is a method. This overrides so +key+ returns Server#key.
|
|
28
47
|
def key #:nodoc:
|
|
29
48
|
self[:key]
|
|
30
49
|
end
|
|
31
50
|
|
|
32
|
-
# Finds the first server that meets the given conditions.
|
|
51
|
+
# Finds the first server that meets the given conditions.
|
|
33
52
|
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
53
|
+
# Scout::Server.first
|
|
54
|
+
# Scout::Server.first(1)
|
|
55
|
+
# Scout::Server.first(:name => 'db slaves')
|
|
56
|
+
# Scout::Server.first(:host => 'web*.geocities')
|
|
38
57
|
#
|
|
39
58
|
#
|
|
40
59
|
# For the <tt>:name</tt> and <tt>:host</tt> options, a {MySQL-formatted Regex}[http://dev.mysql.com/doc/refman/5.0/en/regexp.html] can be used.
|
|
@@ -71,12 +90,12 @@ class Scout::Server < Hashie::Mash
|
|
|
71
90
|
|
|
72
91
|
# Finds all servers that meets the given conditions. Possible parameter formats:
|
|
73
92
|
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
93
|
+
# Scout::Server.all(:name => 'db slaves')
|
|
94
|
+
# Scout::Server.all(:host => 'web*.geocities')
|
|
76
95
|
#
|
|
77
96
|
# For the <tt>:name</tt> and <tt>:host</tt> options, a {MySQL-formatted Regex}[http://dev.mysql.com/doc/refman/5.0/en/regexp.html] can be used.
|
|
78
97
|
#
|
|
79
|
-
# @return [Array] An array of Scout::Server objects
|
|
98
|
+
# @return [Array] An array of {Scout::Server} objects
|
|
80
99
|
def self.all(options = {})
|
|
81
100
|
if name=options[:name]
|
|
82
101
|
response = Scout::Account.get("/clients.xml?name=#{CGI.escape(name)}")
|
|
@@ -90,10 +109,11 @@ class Scout::Server < Hashie::Mash
|
|
|
90
109
|
response['clients'] ? response['clients'].map { |client| Scout::Server.new(client) } : Array.new
|
|
91
110
|
end
|
|
92
111
|
|
|
93
|
-
# Creates a new server
|
|
112
|
+
# Creates a new server with the given <tt>name</tt>. If an error occurs, a [Scout::Error] is raised.
|
|
94
113
|
#
|
|
95
114
|
# An optional existing server id can be used as a template:
|
|
96
|
-
#
|
|
115
|
+
#
|
|
116
|
+
# Scout::Server.create('web server 12',:id => 99999)
|
|
97
117
|
#
|
|
98
118
|
# @return [Scout::Server]
|
|
99
119
|
def self.create(name,options = {})
|
|
@@ -108,6 +128,9 @@ class Scout::Server < Hashie::Mash
|
|
|
108
128
|
|
|
109
129
|
# Delete a server by <tt>id</tt>. If an error occurs, a [Scout::Error] is raised.
|
|
110
130
|
#
|
|
131
|
+
# # Delete server w/id=1
|
|
132
|
+
# ScoutScout::Server.delete(1)
|
|
133
|
+
#
|
|
111
134
|
# @return [true]
|
|
112
135
|
def self.delete(id)
|
|
113
136
|
response = Scout::Account.delete("/#{Scout::Account.param}/clients/#{id}.xml?api_version=#{Scout::VERSION}")
|
|
@@ -123,14 +146,14 @@ class Scout::Server < Hashie::Mash
|
|
|
123
146
|
|
|
124
147
|
# Active alerts for this server
|
|
125
148
|
#
|
|
126
|
-
# @return [Array] An array of Scout::Alert objects
|
|
149
|
+
# @return [Array] An array of {Scout::Alert} objects
|
|
127
150
|
def active_alerts
|
|
128
151
|
@active_alerts ||= @alert_hash.map { |a| decorate_with_server(Scout::Alert.new(a)) }
|
|
129
152
|
end
|
|
130
153
|
|
|
131
154
|
# Recent alerts for this server
|
|
132
155
|
#
|
|
133
|
-
# @return [Array] An array of Scout::Alert objects
|
|
156
|
+
# @return [Array] An array of {Scout::Alert} objects
|
|
134
157
|
def alerts
|
|
135
158
|
response = Scout::Account.get("/clients/#{self.id}/activities.xml")
|
|
136
159
|
response['alerts'].map { |alert| decorate_with_server(Scout::Alert.new(alert)) }
|
|
@@ -138,7 +161,7 @@ class Scout::Server < Hashie::Mash
|
|
|
138
161
|
|
|
139
162
|
# Details about all plugins for this server
|
|
140
163
|
#
|
|
141
|
-
# @return [Array] An array of Scout::Plugin objects
|
|
164
|
+
# @return [Array] An array of {Scout::Plugin }objects
|
|
142
165
|
def plugins
|
|
143
166
|
response = Scout::Account.get("/clients/#{self.id}/plugins.xml")
|
|
144
167
|
response['plugins'].map { |plugin| decorate_with_server(Scout::Plugin.new(plugin)) }
|
|
@@ -154,7 +177,7 @@ class Scout::Server < Hashie::Mash
|
|
|
154
177
|
|
|
155
178
|
# Details about all triggers for this server
|
|
156
179
|
#
|
|
157
|
-
# @return [Array] An array of Scout::Trigger objects
|
|
180
|
+
# @return [Array] An array of {Scout::Trigger} objects
|
|
158
181
|
def triggers
|
|
159
182
|
response = Scout::Account.get("/clients/#{self.id}/triggers.xml")
|
|
160
183
|
response['triggers'].map { |trigger| decorate_with_server(Scout::Trigger.new(trigger)) }
|
data/lib/scout_api/version.rb
CHANGED
data/scout_api.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scout_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 9
|
|
9
7
|
- 1
|
|
10
|
-
|
|
8
|
+
- 0
|
|
9
|
+
- 0
|
|
10
|
+
version: 1.0.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jesse Newland
|