scout_scout 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/README.rdoc +7 -1
- data/Rakefile +1 -0
- data/lib/scout_scout.rb +30 -1
- data/lib/scout_scout/person.rb +3 -0
- data/lib/scout_scout/plugin.rb +23 -1
- data/lib/scout_scout/server.rb +8 -0
- data/lib/scout_scout/trigger.rb +11 -0
- data/lib/scout_scout/version.rb +1 -1
- data/scout_scout.gemspec +84 -0
- data/spec/fixtures/triggers.xml +40 -0
- data/spec/scout_scout_spec.rb +19 -0
- metadata +58 -21
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -21,6 +21,12 @@ A library for extracting data out of Scout[http//:scoutapp.com], a hosted monito
|
|
21
21
|
#details about a specific plugin
|
22
22
|
data = ram_hungry.plugin(12345)
|
23
23
|
|
24
|
+
#detauls on that server's triggers
|
25
|
+
ram_hungry_triggers = ram_hungry.triggers
|
26
|
+
|
27
|
+
#details about triggers for a specific plugin
|
28
|
+
plugin_triggers = ram_hungry.plugin(12345).triggers
|
29
|
+
|
24
30
|
#all available descriptors
|
25
31
|
descriptors = ScoutScout::Descriptor.all
|
26
32
|
|
@@ -49,4 +55,4 @@ information and examples.
|
|
49
55
|
|
50
56
|
== Copyright
|
51
57
|
|
52
|
-
Copyright (c) 2010 Jesse Newland, Derek Haynes. See LICENSE for details.
|
58
|
+
Copyright (c) 2010 Jesse Newland, Derek Haynes. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -17,6 +17,7 @@ begin
|
|
17
17
|
gem.add_development_dependency "fakeweb"
|
18
18
|
gem.add_dependency "hashie", "~> 0.1.8"
|
19
19
|
gem.add_dependency "httparty", "~> 0.5.0"
|
20
|
+
gem.add_dependency "nokogiri"
|
20
21
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
22
|
end
|
22
23
|
Jeweler::GemcutterTasks.new
|
data/lib/scout_scout.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'hashie'
|
2
3
|
require 'httparty'
|
4
|
+
require 'nokogiri'
|
3
5
|
require 'cgi'
|
4
6
|
require 'scout_scout/version'
|
5
7
|
require 'scout_scout/server'
|
6
8
|
require 'scout_scout/descriptor'
|
7
9
|
require 'scout_scout/plugin'
|
10
|
+
require 'scout_scout/trigger'
|
8
11
|
require 'scout_scout/alert'
|
9
12
|
require 'scout_scout/cluster.rb'
|
10
13
|
require 'scout_scout/metric.rb'
|
14
|
+
require 'scout_scout/person'
|
11
15
|
|
12
16
|
class ScoutScout
|
13
17
|
include HTTParty
|
@@ -38,6 +42,31 @@ class ScoutScout
|
|
38
42
|
response = self.class.get("/#{self.class.account}/clients.xml")
|
39
43
|
response['clients'].map { |client| ScoutScout::Server.new(client) }
|
40
44
|
end
|
45
|
+
|
46
|
+
def people
|
47
|
+
response = self.class.get("/#{self.class.account}/account_memberships")
|
48
|
+
doc = Nokogiri::HTML(response.body)
|
49
|
+
|
50
|
+
tables = doc.css('table.list')
|
51
|
+
# first table is pending
|
52
|
+
# second is active
|
53
|
+
active_table = tables.last
|
54
|
+
user_rows = active_table.css('tr')[1..-1] # skip first row, which is headings
|
55
|
+
|
56
|
+
user_rows.map do |row|
|
57
|
+
name_td, email_td, admin_td, links_td = *row.css('td')
|
58
|
+
|
59
|
+
name = name_td.content.gsub(/[\t\n]/, '')
|
60
|
+
email = email_td.content.gsub(/[\t\n]/, '')
|
61
|
+
admin = admin_td.content.gsub(/[\t\n]/, '') == 'Yes'
|
62
|
+
id = if links_td.inner_html =~ %r{/#{self.class.account}/account_memberships/(\d+)}
|
63
|
+
$1.to_i
|
64
|
+
end
|
65
|
+
|
66
|
+
ScoutScout::Person.new :id => id, :name => name, :email => email, :admin => admin
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
41
70
|
|
42
71
|
class << self
|
43
72
|
alias_method :http_get, :get
|
@@ -52,4 +81,4 @@ class ScoutScout
|
|
52
81
|
response.code.to_s =~ /^(4|5)/ ? raise( ScoutScout::Error,response.message) : response
|
53
82
|
end
|
54
83
|
|
55
|
-
end
|
84
|
+
end
|
data/lib/scout_scout/plugin.rb
CHANGED
@@ -16,6 +16,28 @@ class ScoutScout::Plugin < Hashie::Mash
|
|
16
16
|
@descriptors ||= @descriptor_hash.map { |d| decorate_with_server_and_plugin(ScoutScout::Descriptor.new(d)) }
|
17
17
|
end
|
18
18
|
|
19
|
+
def email_subscribers
|
20
|
+
response = ScoutScout.get("/#{ScoutScout.account}/clients/#{server.id}/email_subscribers?plugin_id=#{id}")
|
21
|
+
doc = Nokogiri::HTML(response.body)
|
22
|
+
|
23
|
+
table = doc.css('table.list').first
|
24
|
+
user_rows = table.css('tr')[1..-1] # skip first row, which is headings
|
25
|
+
|
26
|
+
user_rows.map do |row|
|
27
|
+
name_td, receiving_notifications_td = *row.css('td')
|
28
|
+
|
29
|
+
name = name_td.content.gsub(/[\t\n]/, '')
|
30
|
+
checked = receiving_notifications_td.css('input').attribute('checked')
|
31
|
+
receiving_notifications = checked && checked.value == 'checked'
|
32
|
+
Hashie::Mash.new :name => name, :receiving_notifications => receiving_notifications
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def triggers
|
37
|
+
response = ScoutScout.get("/#{ScoutScout.account}/clients/#{server.id}/triggers.xml?plugin_id=#{id}")
|
38
|
+
response['triggers'].map { |trigger| decorate_with_server_and_plugin(ScoutScout::Trigger.new(trigger)) }
|
39
|
+
end
|
40
|
+
|
19
41
|
protected
|
20
42
|
|
21
43
|
def decorate_with_server_and_plugin(hashie)
|
@@ -24,4 +46,4 @@ protected
|
|
24
46
|
hashie
|
25
47
|
end
|
26
48
|
|
27
|
-
end
|
49
|
+
end
|
data/lib/scout_scout/server.rb
CHANGED
@@ -71,6 +71,14 @@ class ScoutScout::Server < Hashie::Mash
|
|
71
71
|
ScoutScout::Descriptor.all(:host => hostname).map { |d| decorate_with_server(d) }
|
72
72
|
end
|
73
73
|
|
74
|
+
# Details about all triggers for this server
|
75
|
+
#
|
76
|
+
# @return [Array] An array of ScoutScout::Trigger objects
|
77
|
+
def triggers
|
78
|
+
response = ScoutScout.get("/#{ScoutScout.account}/clients/#{self.id}/triggers.xml")
|
79
|
+
response['triggers'].map { |trigger| decorate_with_server(ScoutScout::Trigger.new(trigger)) }
|
80
|
+
end
|
81
|
+
|
74
82
|
protected
|
75
83
|
|
76
84
|
def decorate_with_server(hashie)
|
data/lib/scout_scout/version.rb
CHANGED
data/scout_scout.gemspec
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{scout_scout}
|
8
|
+
s.version = "0.0.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jesse Newland"]
|
12
|
+
s.date = %q{2010-07-15}
|
13
|
+
s.description = %q{API wrapper for scout.com}
|
14
|
+
s.email = %q{jnewland@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"lib/scout_scout.rb",
|
26
|
+
"lib/scout_scout/alert.rb",
|
27
|
+
"lib/scout_scout/cluster.rb",
|
28
|
+
"lib/scout_scout/descriptor.rb",
|
29
|
+
"lib/scout_scout/metric.rb",
|
30
|
+
"lib/scout_scout/person.rb",
|
31
|
+
"lib/scout_scout/plugin.rb",
|
32
|
+
"lib/scout_scout/server.rb",
|
33
|
+
"lib/scout_scout/trigger.rb",
|
34
|
+
"lib/scout_scout/version.rb",
|
35
|
+
"scout_scout.gemspec",
|
36
|
+
"spec/fixtures/activities.xml",
|
37
|
+
"spec/fixtures/client.xml",
|
38
|
+
"spec/fixtures/client_by_hostname.xml",
|
39
|
+
"spec/fixtures/clients.xml",
|
40
|
+
"spec/fixtures/data.xml",
|
41
|
+
"spec/fixtures/descriptors.xml",
|
42
|
+
"spec/fixtures/plugin_data.xml",
|
43
|
+
"spec/fixtures/plugins.xml",
|
44
|
+
"spec/fixtures/triggers.xml",
|
45
|
+
"spec/scout_scout_spec.rb",
|
46
|
+
"spec/spec.opts",
|
47
|
+
"spec/spec_helper.rb"
|
48
|
+
]
|
49
|
+
s.homepage = %q{http://github.com/jnewland/scout_scout}
|
50
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubygems_version = %q{1.3.6}
|
53
|
+
s.summary = %q{API wrapper for scout.com}
|
54
|
+
s.test_files = [
|
55
|
+
"spec/scout_scout_spec.rb",
|
56
|
+
"spec/spec_helper.rb"
|
57
|
+
]
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
+
s.specification_version = 3
|
62
|
+
|
63
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
65
|
+
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
66
|
+
s.add_runtime_dependency(%q<hashie>, ["~> 0.1.8"])
|
67
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.5.0"])
|
68
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
71
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
72
|
+
s.add_dependency(%q<hashie>, ["~> 0.1.8"])
|
73
|
+
s.add_dependency(%q<httparty>, ["~> 0.5.0"])
|
74
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
78
|
+
s.add_dependency(%q<fakeweb>, [">= 0"])
|
79
|
+
s.add_dependency(%q<hashie>, ["~> 0.1.8"])
|
80
|
+
s.add_dependency(%q<httparty>, ["~> 0.5.0"])
|
81
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<triggers type="array">
|
3
|
+
<trigger>
|
4
|
+
<id type="integer">119871</id>
|
5
|
+
<last-fired-at type="datetime">2010-04-08T04:10:00-04:00</last-fired-at>
|
6
|
+
<max-value type="float">85.0</max-value>
|
7
|
+
<min-value type="float">0.0</min-value>
|
8
|
+
<plugin-id type="integer">136421</plugin-id>
|
9
|
+
<sms-max-value type="float">90.0</sms-max-value>
|
10
|
+
<sms-percentage-change type="integer" nil="true"></sms-percentage-change>
|
11
|
+
<simple-type>peak</simple-type>
|
12
|
+
<title>Alert me when Disk Capacity exceeds 85%. SMS alert at 90%.</title>
|
13
|
+
<descriptor-label>Disk Capacity</descriptor-label>
|
14
|
+
</trigger>
|
15
|
+
<trigger>
|
16
|
+
<id type="integer">152031</id>
|
17
|
+
<last-fired-at type="datetime">2010-04-29T14:45:00-04:00</last-fired-at>
|
18
|
+
<max-value type="float">85.0</max-value>
|
19
|
+
<min-value type="float">0.0</min-value>
|
20
|
+
<plugin-id type="integer">136421</plugin-id>
|
21
|
+
<sms-max-value type="float">90.0</sms-max-value>
|
22
|
+
<sms-percentage-change type="integer" nil="true"></sms-percentage-change>
|
23
|
+
<simple-type>peak</simple-type>
|
24
|
+
<title>Alert me when % Memory Used exceeds 85%. SMS alert at 90%.</title>
|
25
|
+
<descriptor-label>% Memory Used</descriptor-label>
|
26
|
+
</trigger>
|
27
|
+
<trigger>
|
28
|
+
<id type="integer">119921</id>
|
29
|
+
<last-fired-at type="datetime" nil="true"></last-fired-at>
|
30
|
+
<max-value type="float">1.0</max-value>
|
31
|
+
<min-value type="float">0.0</min-value>
|
32
|
+
<plugin-id type="integer">136451</plugin-id>
|
33
|
+
<sms-max-value type="float">10.0</sms-max-value>
|
34
|
+
<sms-percentage-change type="integer" nil="true"></sms-percentage-change>
|
35
|
+
<simple-type>peak</simple-type>
|
36
|
+
<title>Alert me when Passenger Global Queue Depth exceeds 1 . SMS alert at 10 .</title>
|
37
|
+
<descriptor-label>Passenger Global Queue Depth</descriptor-label>
|
38
|
+
</trigger>
|
39
|
+
</triggers>
|
40
|
+
|
data/spec/scout_scout_spec.rb
CHANGED
@@ -155,6 +155,25 @@ describe "ScoutScout" do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
end
|
158
|
+
describe 'trigger' do
|
159
|
+
describe 'list' do
|
160
|
+
before(:each) do
|
161
|
+
@scout_scout.stub_get('clients/13431.xml', 'client.xml')
|
162
|
+
@server = ScoutScout::Server.first(13431)
|
163
|
+
@scout_scout.stub_get('clients/13431/triggers.xml', 'triggers.xml')
|
164
|
+
@triggers = @server.triggers
|
165
|
+
end
|
166
|
+
it "should be accessable" do
|
167
|
+
@triggers.size.should == 3
|
168
|
+
@triggers.each do |trigger|
|
169
|
+
trigger.simple_type.should == 'peak'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
it "should be an array of ScoutScout::Trigger objects" do
|
173
|
+
@triggers.first.class.should == ScoutScout::Trigger
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
158
177
|
describe 'descriptor list' do
|
159
178
|
before(:each) do
|
160
179
|
@scout_scout.stub_get('clients/13431.xml', 'client.xml')
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Jesse Newland
|
@@ -9,49 +14,75 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-07-15 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - "="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
- 0
|
23
31
|
version: 1.3.0
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: fakeweb
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
33
43
|
version: "0"
|
34
|
-
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
35
46
|
- !ruby/object:Gem::Dependency
|
36
47
|
name: hashie
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
- 1
|
56
|
+
- 8
|
43
57
|
version: 0.1.8
|
44
|
-
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
45
60
|
- !ruby/object:Gem::Dependency
|
46
61
|
name: httparty
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ~>
|
52
66
|
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
- 5
|
70
|
+
- 0
|
53
71
|
version: 0.5.0
|
54
|
-
|
72
|
+
type: :runtime
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: nokogiri
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
type: :runtime
|
85
|
+
version_requirements: *id005
|
55
86
|
description: API wrapper for scout.com
|
56
87
|
email: jnewland@gmail.com
|
57
88
|
executables: []
|
@@ -72,9 +103,12 @@ files:
|
|
72
103
|
- lib/scout_scout/cluster.rb
|
73
104
|
- lib/scout_scout/descriptor.rb
|
74
105
|
- lib/scout_scout/metric.rb
|
106
|
+
- lib/scout_scout/person.rb
|
75
107
|
- lib/scout_scout/plugin.rb
|
76
108
|
- lib/scout_scout/server.rb
|
109
|
+
- lib/scout_scout/trigger.rb
|
77
110
|
- lib/scout_scout/version.rb
|
111
|
+
- scout_scout.gemspec
|
78
112
|
- spec/fixtures/activities.xml
|
79
113
|
- spec/fixtures/client.xml
|
80
114
|
- spec/fixtures/client_by_hostname.xml
|
@@ -83,6 +117,7 @@ files:
|
|
83
117
|
- spec/fixtures/descriptors.xml
|
84
118
|
- spec/fixtures/plugin_data.xml
|
85
119
|
- spec/fixtures/plugins.xml
|
120
|
+
- spec/fixtures/triggers.xml
|
86
121
|
- spec/scout_scout_spec.rb
|
87
122
|
- spec/spec.opts
|
88
123
|
- spec/spec_helper.rb
|
@@ -99,18 +134,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
134
|
requirements:
|
100
135
|
- - ">="
|
101
136
|
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
102
139
|
version: "0"
|
103
|
-
version:
|
104
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
141
|
requirements:
|
106
142
|
- - ">="
|
107
143
|
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
108
146
|
version: "0"
|
109
|
-
version:
|
110
147
|
requirements: []
|
111
148
|
|
112
149
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.3.
|
150
|
+
rubygems_version: 1.3.6
|
114
151
|
signing_key:
|
115
152
|
specification_version: 3
|
116
153
|
summary: API wrapper for scout.com
|