scout 1.1.8 → 2.0.4
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 → History.txt} +28 -0
- data/{LICENSE → License.txt} +2 -1
- data/Manifest.txt +33 -0
- data/PostInstall.txt +7 -0
- data/README.txt +76 -0
- data/Rakefile +4 -134
- data/bin/scout +1 -200
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/scout/command/clone.rb +21 -0
- data/lib/scout/command/install.rb +62 -0
- data/lib/scout/command/run.rb +14 -0
- data/lib/scout/command/test.rb +38 -0
- data/lib/scout/command.rb +225 -0
- data/lib/scout/plugin.rb +97 -1
- data/lib/scout/server.rb +24 -2
- data/lib/scout/version.rb +9 -0
- data/lib/scout.rb +2 -4
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +799 -574
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_scout.rb +11 -0
- data/website/index.html +138 -0
- data/website/index.txt +81 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +61 -34
- data/AUTHORS +0 -4
- data/COPYING +0 -340
- data/INSTALL +0 -18
- data/README +0 -34
- data/TODO +0 -6
- data/test/scout_test.rb +0 -91
data/{CHANGELOG → History.txt}
RENAMED
@@ -1,3 +1,31 @@
|
|
1
|
+
== 2.0.4 2008-07-18
|
2
|
+
|
3
|
+
* Switched to NewGem/Hoe Generators to generate gem
|
4
|
+
|
5
|
+
== 2.0.3
|
6
|
+
|
7
|
+
* Added documentation for Scout#data_for_server method for new plugin creation
|
8
|
+
* Added Version option for printing the current version
|
9
|
+
* Removed a spurious "puts" debug statement
|
10
|
+
|
11
|
+
== 2.0.2
|
12
|
+
|
13
|
+
* Fixed the logging bug I introduced by moving the PID check into the Command
|
14
|
+
class
|
15
|
+
|
16
|
+
== 2.0.1
|
17
|
+
|
18
|
+
* Added some safety code to ensure SystemExit exceptions are not caught in our
|
19
|
+
rescue clauses
|
20
|
+
|
21
|
+
== 2.0.0
|
22
|
+
|
23
|
+
* Reworked scout executable to work off an underlying command structure, similar
|
24
|
+
to Subversion (a bare call and a call with just the key are supported for
|
25
|
+
backward compatibility)
|
26
|
+
* Added various helper functions to Scout::Plugin to ease development
|
27
|
+
* Added a client clone command for instant setups
|
28
|
+
|
1
29
|
== 1.1.8
|
2
30
|
|
3
31
|
* Rectifying missing checkin -- this unifies 1.1.6 and 1.1.7 changes to gem
|
data/{LICENSE → License.txt}
RENAMED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
Copyright (c) 2008 Highgroove Studios
|
2
2
|
|
3
3
|
Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
|
4
4
|
{Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt].
|
5
5
|
|
6
6
|
Please contact {Highroove Studios}[http://www.highgroove.com] with any questions.
|
7
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
bin/scout
|
8
|
+
config/hoe.rb
|
9
|
+
config/requirements.rb
|
10
|
+
lib/scout.rb
|
11
|
+
lib/scout/version.rb
|
12
|
+
lib/scout/server.rb
|
13
|
+
lib/scout/plugin.rb
|
14
|
+
lib/scout/command.rb
|
15
|
+
lib/scout/command/clone.rb
|
16
|
+
lib/scout/command/install.rb
|
17
|
+
lib/scout/command/run.rb
|
18
|
+
lib/scout/command/test.rb
|
19
|
+
script/console
|
20
|
+
script/destroy
|
21
|
+
script/generate
|
22
|
+
script/txt2html
|
23
|
+
setup.rb
|
24
|
+
tasks/deployment.rake
|
25
|
+
tasks/environment.rake
|
26
|
+
tasks/website.rake
|
27
|
+
test/test_helper.rb
|
28
|
+
test/test_scout.rb
|
29
|
+
website/index.html
|
30
|
+
website/index.txt
|
31
|
+
website/javascripts/rounded_corners_lite.inc.js
|
32
|
+
website/stylesheets/screen.css
|
33
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
= scout
|
2
|
+
|
3
|
+
* http://scout.rubyforge.org/
|
4
|
+
* http://scoutapp.com/
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
The easier way to monitor servers and web applications.
|
9
|
+
|
10
|
+
Scout makes monitoring and reporting on your web applications as flexible
|
11
|
+
and simple as possible.
|
12
|
+
|
13
|
+
Scout is a product of Highgroove Studios. Please visit http://scoutapp.com
|
14
|
+
for more information.
|
15
|
+
|
16
|
+
== FEATURES/PROBLEMS:
|
17
|
+
|
18
|
+
* Easy to Install
|
19
|
+
* Leverage the Scout Plugin Community
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
The Scout client has several modes of operation and commands. The normal, intended usage is through a scheduled interval with no output.
|
24
|
+
|
25
|
+
Normal checkin with server:
|
26
|
+
$ scout [OPTIONS] CLIENT_KEY
|
27
|
+
... OR ...
|
28
|
+
$ scout [OPTIONS] run CLIENT_KEY
|
29
|
+
|
30
|
+
Install:
|
31
|
+
$ scout
|
32
|
+
... OR ...
|
33
|
+
$ scout [OPTIONS] install
|
34
|
+
|
35
|
+
Local plugin testing:
|
36
|
+
$ scout [OPTIONS] test PATH_TO_PLUGIN [PLUGIN_OPTIONS]
|
37
|
+
|
38
|
+
Clone a client setup:
|
39
|
+
$ scout [OPTIONS] clone CLIENT_KEY NEW_CLIENT_NAME
|
40
|
+
|
41
|
+
CLIENT_KEY is the indentification key assigned to
|
42
|
+
this client by the server.
|
43
|
+
|
44
|
+
PATH_TO_PLUGIN is the file system path to a Ruby file
|
45
|
+
that contains a Scout plugin.
|
46
|
+
|
47
|
+
PLUGIN_OPTIONS can be the code for a Ruby Hash or the
|
48
|
+
path to a YAML options file containing defaults. These
|
49
|
+
options will be used for the plugin run.
|
50
|
+
|
51
|
+
NEW_CLIENT_NAME is name you wish to use for the new
|
52
|
+
client the server creates.
|
53
|
+
|
54
|
+
== REQUIREMENTS:
|
55
|
+
|
56
|
+
* elif gem
|
57
|
+
|
58
|
+
== INSTALL:
|
59
|
+
|
60
|
+
After installing the scout gem:
|
61
|
+
|
62
|
+
$ sudo gem install scout
|
63
|
+
|
64
|
+
Simply run:
|
65
|
+
|
66
|
+
$ scout
|
67
|
+
|
68
|
+
to run the installation wizard. You'll need your Client Key to continue.
|
69
|
+
|
70
|
+
== LICENSE:
|
71
|
+
|
72
|
+
Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
|
73
|
+
{Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt].
|
74
|
+
|
75
|
+
Please contact {Highroove Studios}[http://www.highgroove.com] with any questions.
|
76
|
+
|
data/Rakefile
CHANGED
@@ -1,134 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
require "net/ssh"
|
6
|
-
|
7
|
-
require "rubygems"
|
8
|
-
require "rubyforge"
|
9
|
-
|
10
|
-
dir = File.dirname(__FILE__)
|
11
|
-
lib = File.join(dir, "lib", "scout.rb")
|
12
|
-
version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2]
|
13
|
-
history = File.read("CHANGELOG").split(/^(===.*)/)
|
14
|
-
changes ||= history[0..2].join.strip
|
15
|
-
|
16
|
-
need_tar = true
|
17
|
-
need_zip = true
|
18
|
-
|
19
|
-
task :default => [:test]
|
20
|
-
|
21
|
-
Rake::TestTask.new do |test|
|
22
|
-
test.libs << "test"
|
23
|
-
test.test_files = [ "test/scout_test.rb" ]
|
24
|
-
test.verbose = true
|
25
|
-
end
|
26
|
-
|
27
|
-
Rake::RDocTask.new do |rdoc|
|
28
|
-
rdoc.main = "README"
|
29
|
-
rdoc.rdoc_dir = "doc/html"
|
30
|
-
rdoc.title = "Scout Client Documentation"
|
31
|
-
rdoc.rdoc_files.include( "README", "INSTALL",
|
32
|
-
"TODO", "CHANGELOG",
|
33
|
-
"AUTHORS", "COPYING",
|
34
|
-
"LICENSE", "lib/" )
|
35
|
-
end
|
36
|
-
|
37
|
-
spec = Gem::Specification.new do |spec|
|
38
|
-
spec.name = "scout"
|
39
|
-
spec.version = version
|
40
|
-
|
41
|
-
spec.platform = Gem::Platform::RUBY
|
42
|
-
spec.summary = "Scout makes monitoring and reporting on your web applications as flexible and simple as possible."
|
43
|
-
|
44
|
-
# TODO: test suite
|
45
|
-
# spec.test_suite_file = "test/ts_all.rb"
|
46
|
-
spec.files = Dir.glob("{lib,test,examples}/**/*.rb").
|
47
|
-
reject { |item| item.include?(".svn") } +
|
48
|
-
Dir.glob("{test,examples}/**/*.csv").
|
49
|
-
reject { |item| item.include?(".svn") } +
|
50
|
-
["Rakefile", "setup.rb"]
|
51
|
-
spec.executables = ["scout"]
|
52
|
-
|
53
|
-
spec.has_rdoc = true
|
54
|
-
spec.extra_rdoc_files = %w[ AUTHORS COPYING README INSTALL TODO CHANGELOG
|
55
|
-
LICENSE ]
|
56
|
-
spec.rdoc_options << "--title" << "Scout Client Documentation" <<
|
57
|
-
"--main" << "README"
|
58
|
-
|
59
|
-
spec.require_path = "lib"
|
60
|
-
|
61
|
-
spec.add_dependency "elif"
|
62
|
-
# spec.add_dependency "hpricot", "=0.6"
|
63
|
-
|
64
|
-
spec.author = "Highgroove Studios"
|
65
|
-
spec.email = "scout@highgroove.com"
|
66
|
-
spec.rubyforge_project = "scout"
|
67
|
-
spec.homepage = "http://scoutapp.com"
|
68
|
-
spec.description = <<END_DESC
|
69
|
-
Scout makes monitoring and reporting on your web applications as flexible and simple as possible.
|
70
|
-
|
71
|
-
Scout is a product of Highgroove Studios.
|
72
|
-
END_DESC
|
73
|
-
end
|
74
|
-
|
75
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
76
|
-
pkg.need_zip = need_tar
|
77
|
-
pkg.need_tar = need_zip
|
78
|
-
end
|
79
|
-
|
80
|
-
desc "Publishes to Scout Gem Server and Rubyforge"
|
81
|
-
task :publish => [:package, :publish_scout, :publish_rubyforge]
|
82
|
-
|
83
|
-
desc "Publish Gem to Scout Gem Server"
|
84
|
-
task :publish_scout => [:package] do
|
85
|
-
|
86
|
-
puts "Publishing on Scout Server"
|
87
|
-
sh "scp -r pkg/*.gem " +
|
88
|
-
"deploy@gems.scoutapp.com:/var/www/gems/gems"
|
89
|
-
ssh = Net::SSH.start('gems.scoutapp.com','deploy')
|
90
|
-
ssh_shell = ssh.shell.sync
|
91
|
-
ssh_out = ssh_shell.send_command "/usr/bin/gem generate_index -d /var/www/gems"
|
92
|
-
puts "Published, and updated gem server." if ssh_out.stdout.empty? && !ssh_out.stderr
|
93
|
-
end
|
94
|
-
|
95
|
-
desc "Publishes Gem to Rubyforge"
|
96
|
-
task :publish_rubyforge => [:package] do
|
97
|
-
pkg = "pkg/#{spec.name}-#{version}"
|
98
|
-
|
99
|
-
if $DEBUG then
|
100
|
-
puts "release_id = rf.add_release #{spec.rubyforge_project.inspect}, #{spec.name.inspect}, #{spec.version.inspect}, \"#{pkg}.tgz\""
|
101
|
-
puts "rf.add_file #{spec.rubyforge_project.inspect}, #{spec.name.inspect}, release_id, \"#{pkg}.gem\""
|
102
|
-
end
|
103
|
-
|
104
|
-
puts "Publishing on RubyForge"
|
105
|
-
rf = RubyForge.new
|
106
|
-
puts "Logging in"
|
107
|
-
rf.login
|
108
|
-
|
109
|
-
c = rf.userconfig
|
110
|
-
c["release_notes"] = spec.description if spec.description
|
111
|
-
c["release_changes"] = changes if changes
|
112
|
-
c["preformatted"] = true
|
113
|
-
|
114
|
-
files = [(need_tar ? "#{pkg}.tgz" : nil),
|
115
|
-
(need_zip ? "#{pkg}.zip" : nil),
|
116
|
-
"#{pkg}.gem"].compact
|
117
|
-
|
118
|
-
puts "Releasing #{spec.name} v. #{version}"
|
119
|
-
rf.add_release spec.rubyforge_project, spec.name, version, *files
|
120
|
-
end
|
121
|
-
|
122
|
-
desc "Upload current documentation to Scout Gem Server and RubyForge"
|
123
|
-
task :upload_docs => [:rdoc] do
|
124
|
-
sh "scp -r doc/html/* " +
|
125
|
-
"deploy@gems.scoutapp.com:/var/www/gems/docs"
|
126
|
-
|
127
|
-
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
128
|
-
host = "#{config["username"]}@rubyforge.org"
|
129
|
-
|
130
|
-
remote_dir = "/var/www/gforge-projects/#{spec.rubyforge_project}"
|
131
|
-
local_dir = 'doc/html'
|
132
|
-
|
133
|
-
sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
|
134
|
-
end
|
1
|
+
require 'config/requirements'
|
2
|
+
require 'config/hoe' # setup Hoe + all gem configuration
|
3
|
+
|
4
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
data/bin/scout
CHANGED
@@ -5,204 +5,5 @@ $KCODE = "u" # -Ku
|
|
5
5
|
|
6
6
|
$LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. lib])
|
7
7
|
require "scout"
|
8
|
-
require "optparse"
|
9
|
-
require "logger"
|
10
|
-
require "fileutils"
|
11
|
-
require "pp"
|
12
8
|
|
13
|
-
|
14
|
-
USER = ENV["USER"] || ENV["USERNAME"] || "root"
|
15
|
-
|
16
|
-
options = { :server => "https://scoutapp.com/",
|
17
|
-
:history => File.join(CONFIG_DIR , "client_history.yaml"),
|
18
|
-
:verbose => false,
|
19
|
-
:level => "info" }
|
20
|
-
|
21
|
-
ARGV.options do |opts|
|
22
|
-
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] CLIENT_KEY"
|
23
|
-
|
24
|
-
opts.separator ""
|
25
|
-
opts.separator "CLIENT_KEY is the indentification key assigned to this " +
|
26
|
-
"client by the server."
|
27
|
-
opts.separator ""
|
28
|
-
opts.separator "Note: This client is meant to be installed and invoked " +
|
29
|
-
"through cron or any other scheduler."
|
30
|
-
opts.separator ""
|
31
|
-
opts.separator "Specific Options:"
|
32
|
-
|
33
|
-
opts.on( "-s", "--server SERVER", String,
|
34
|
-
"The URL for the server this client reports to." ) do |url|
|
35
|
-
options[:server] = url
|
36
|
-
end
|
37
|
-
opts.on( "-p", "--plugin PLUGIN", String,
|
38
|
-
"The path to a plugin to run locally. " +
|
39
|
-
"Useful for Testing." ) do |plugin|
|
40
|
-
options[:plugin] = plugin
|
41
|
-
end
|
42
|
-
|
43
|
-
opts.separator ""
|
44
|
-
|
45
|
-
opts.on( "-d", "--data DATA", String,
|
46
|
-
"The data file used to track the history of executions." ) do |file|
|
47
|
-
options[:history] = file
|
48
|
-
end
|
49
|
-
opts.on( "-l", "--level LEVEL", Logger::SEV_LABEL.map { |l| l.downcase },
|
50
|
-
"The level of logging to report." ) do |level|
|
51
|
-
options[:level] = level
|
52
|
-
end
|
53
|
-
opts.on( "-o", "--plugin-options PLUGIN_OPTIONS", String,
|
54
|
-
"The options YAML file to pass to the plugin." ) do |plugin_options|
|
55
|
-
options[:plugin_options] = plugin_options
|
56
|
-
end
|
57
|
-
|
58
|
-
opts.separator "Common Options:"
|
59
|
-
|
60
|
-
opts.on( "-h", "--help",
|
61
|
-
"Show this message." ) do
|
62
|
-
puts opts
|
63
|
-
exit
|
64
|
-
end
|
65
|
-
opts.on( "-v", "--[no-]verbose",
|
66
|
-
"Turn on logging to STDOUT" ) do |bool|
|
67
|
-
options[:verbose] = bool
|
68
|
-
end
|
69
|
-
|
70
|
-
begin
|
71
|
-
opts.parse!
|
72
|
-
options[:client_key] = ARGV.shift if ARGV.size == 1
|
73
|
-
rescue
|
74
|
-
puts opts
|
75
|
-
exit
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
log = Logger.new($stdout)
|
80
|
-
log.datetime_format = "%Y-%m-%d %H:%M:%S "
|
81
|
-
log.level = Logger.const_get(options[:level].upcase) \
|
82
|
-
rescue Logger::INFO
|
83
|
-
|
84
|
-
real_config_dir = File.dirname(options[:history])
|
85
|
-
FileUtils.mkdir_p(real_config_dir) # ensure dir exists
|
86
|
-
|
87
|
-
# make sure only one copy is ever running at a time
|
88
|
-
pid_file = File.join(real_config_dir, "scout_client_pid.txt")
|
89
|
-
begin
|
90
|
-
File.open(pid_file, File::CREAT|File::EXCL|File::WRONLY) { |pid| pid.puts $$ }
|
91
|
-
at_exit do
|
92
|
-
begin
|
93
|
-
File.unlink(pid_file)
|
94
|
-
rescue
|
95
|
-
log.error "Unable to unlink pid file: #{$!.message}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
rescue
|
99
|
-
pid = File.read(pid_file).strip.to_i rescue "unknown"
|
100
|
-
running = true
|
101
|
-
begin
|
102
|
-
Process.kill(0, pid)
|
103
|
-
rescue Errno::ESRCH
|
104
|
-
running = false
|
105
|
-
rescue
|
106
|
-
# do nothing, we didn't have permission to the running process
|
107
|
-
end
|
108
|
-
if running
|
109
|
-
log.warn "Process #{pid} was already running"
|
110
|
-
exit
|
111
|
-
else
|
112
|
-
log.info "Stale PID file found. Clearing it and reloading..."
|
113
|
-
File.unlink(pid_file)
|
114
|
-
retry
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
if [:client_key, :plugin].all? { |o| options[o].nil? } and
|
119
|
-
$stdin.tty? # install wizard
|
120
|
-
puts <<-END_INTRO.gsub(/^ {2}/, "")
|
121
|
-
== Scout Installation Wizard ==
|
122
|
-
|
123
|
-
You need the Client Key displayed in the Client Settings
|
124
|
-
tab. It looks like:
|
125
|
-
|
126
|
-
6ecad322-0d17-4cb8-9b2c-a12c4541853f
|
127
|
-
|
128
|
-
Enter the Client Key:
|
129
|
-
END_INTRO
|
130
|
-
options[:client_key] = gets.to_s.strip
|
131
|
-
|
132
|
-
# puts "Attempting to contact the server..."
|
133
|
-
begin
|
134
|
-
Scout::Server.new( options[:server],
|
135
|
-
options[:client_key],
|
136
|
-
options[:history],
|
137
|
-
options[:verbose] ? log : nil ) { |server| server.test }
|
138
|
-
|
139
|
-
puts <<-END_SUCCESS.gsub(/^ {4}/, "")
|
140
|
-
|
141
|
-
Success!
|
142
|
-
|
143
|
-
Now, you must setup Scout to run on a scheduled basis.
|
144
|
-
|
145
|
-
If you are using the system crontab (usually located at /etc/crontab):
|
146
|
-
|
147
|
-
****** START CRONTAB SAMPLE ******
|
148
|
-
*/30 * * * * #{USER} #{File.expand_path($PROGRAM_NAME)} #{options[:client_key]}
|
149
|
-
******* END CRONTAB SAMPLE *******
|
150
|
-
|
151
|
-
If you are using this current user's crontab (using crontab -e to edit):
|
152
|
-
|
153
|
-
****** START CRONTAB SAMPLE ******
|
154
|
-
*/30 * * * * #{File.expand_path($PROGRAM_NAME)} #{options[:client_key]}
|
155
|
-
******* END CRONTAB SAMPLE *******
|
156
|
-
|
157
|
-
For help setting up Scout with crontab, please visit:
|
158
|
-
|
159
|
-
http://scoutapp.com/help#cron
|
160
|
-
|
161
|
-
END_SUCCESS
|
162
|
-
rescue SystemExit
|
163
|
-
puts <<-END_ERROR.gsub(/^ {4}/, "")
|
164
|
-
|
165
|
-
Could not contact server. The client key may be incorrect. For more help,
|
166
|
-
please visit:
|
167
|
-
|
168
|
-
http://scoutapp.com/help
|
169
|
-
|
170
|
-
END_ERROR
|
171
|
-
end
|
172
|
-
elsif options[:plugin] # local plugin
|
173
|
-
# read the plugin_code from the file specified
|
174
|
-
plugin_code = File.read(options[:plugin])
|
175
|
-
|
176
|
-
plugin_options = if options[:plugin_options].to_s[0..0] == "{"
|
177
|
-
eval(options[:plugin_options]) # options from command-line
|
178
|
-
elsif options[:plugin_options]
|
179
|
-
#
|
180
|
-
# read the plugin_options from the YAML file specified,
|
181
|
-
# parse each option and use the default value specified
|
182
|
-
# in the options as the value to be passed to the test plugin
|
183
|
-
#
|
184
|
-
Hash[ *File.open(options[:plugin_options]) { |f| YAML.load(f) }["options"].
|
185
|
-
map { |name, details| [name, details["default"]] }.flatten ]
|
186
|
-
else
|
187
|
-
Hash.new
|
188
|
-
end
|
189
|
-
|
190
|
-
Scout::Server.new( nil,
|
191
|
-
options[:client_key],
|
192
|
-
options[:history],
|
193
|
-
options[:verbose] ? log : nil ) do |server|
|
194
|
-
pp server.process_plugin( { :interval => 0,
|
195
|
-
:plugin_id => 1,
|
196
|
-
:name => "Local Plugin",
|
197
|
-
:code => plugin_code,
|
198
|
-
:options => plugin_options,
|
199
|
-
:path => options[:plugin] } )
|
200
|
-
end
|
201
|
-
else # normal run
|
202
|
-
Scout::Server.new( options[:server],
|
203
|
-
options[:client_key],
|
204
|
-
options[:history],
|
205
|
-
options[:verbose] ? log : nil ) do |server|
|
206
|
-
server.run_plugins_by_plan
|
207
|
-
end
|
208
|
-
end
|
9
|
+
Scout::Command.dispatch(ARGV)
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'scout/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Charles Brian Quinn'
|
4
|
+
EMAIL = "hello@highgroove.com"
|
5
|
+
DESCRIPTION = "Scout is a simple web monitoring and reporting client. It can connect to a plugin server, download plugins (written in Ruby) and run them on at specified intervals."
|
6
|
+
GEM_NAME = 'scout'
|
7
|
+
RUBYFORGE_PROJECT = 'scout'
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
['elif', '>= 0.1.0']
|
12
|
+
]
|
13
|
+
|
14
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
+
@config = nil
|
16
|
+
RUBYFORGE_USERNAME = "seebq"
|
17
|
+
def rubyforge_username
|
18
|
+
unless @config
|
19
|
+
begin
|
20
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
+
EOS
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
37
|
+
VERS = Scout::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
+
RDOC_OPTS = ['--quiet', '--title', 'scout documentation',
|
39
|
+
"--opname", "index.html",
|
40
|
+
"--line-numbers",
|
41
|
+
"--main", "README",
|
42
|
+
"--inline-source"]
|
43
|
+
|
44
|
+
class Hoe
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
+
@extra_deps
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generate all the Rake tasks
|
52
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
+
p.developer(AUTHOR, EMAIL)
|
55
|
+
p.description = DESCRIPTION
|
56
|
+
p.summary = DESCRIPTION
|
57
|
+
p.url = HOMEPATH
|
58
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
59
|
+
p.test_globs = ["test/**/test_*.rb"]
|
60
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
61
|
+
|
62
|
+
# == Optional
|
63
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
64
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
+
|
66
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
+
end
|
68
|
+
|
69
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
73
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module Scout
|
6
|
+
class Command
|
7
|
+
class Clone < Command
|
8
|
+
def run
|
9
|
+
key, name = @args
|
10
|
+
abort usage if [key, name].any? { |arg| arg.nil? or arg.empty? }
|
11
|
+
|
12
|
+
Scout::Server.new(server, key, history, log) do |scout|
|
13
|
+
scout.clone_client(
|
14
|
+
name,
|
15
|
+
"*/30 * * * * #{user} #{program_path} CLIENT_KEY"
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
|
3
|
+
module Scout
|
4
|
+
class Command
|
5
|
+
class Install < Command
|
6
|
+
def run
|
7
|
+
abort usage unless $stdin.tty?
|
8
|
+
|
9
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
10
|
+
=== Scout Installation Wizard ===
|
11
|
+
|
12
|
+
You need the Client Key displayed in the Client Settings tab.
|
13
|
+
It looks like:
|
14
|
+
|
15
|
+
6ecad322-0d17-4cb8-9b2c-a12c4541853f
|
16
|
+
|
17
|
+
Enter the Client Key:
|
18
|
+
END_INTRO
|
19
|
+
key = gets.to_s.strip
|
20
|
+
|
21
|
+
puts "\nAttempting to contact the server..."
|
22
|
+
begin
|
23
|
+
Scout::Server.new(server, key, history, log) { |scout| scout.test }
|
24
|
+
|
25
|
+
puts <<-END_SUCCESS.gsub(/^ {10}/, "")
|
26
|
+
Success!
|
27
|
+
|
28
|
+
Now, you must setup Scout to run on a scheduled basis.
|
29
|
+
|
30
|
+
If you are using the system crontab
|
31
|
+
(usually located at /etc/crontab):
|
32
|
+
|
33
|
+
****** START CRONTAB SAMPLE ******
|
34
|
+
*/30 * * * * #{user} #{program_path} #{key}
|
35
|
+
****** END CRONTAB SAMPLE ******
|
36
|
+
|
37
|
+
If you are using this current user's crontab
|
38
|
+
(using crontab -e to edit):
|
39
|
+
|
40
|
+
****** START CRONTAB SAMPLE ******
|
41
|
+
*/30 * * * * #{program_path} #{key}
|
42
|
+
****** END CRONTAB SAMPLE ******
|
43
|
+
|
44
|
+
For help setting up Scout with crontab, please visit:
|
45
|
+
|
46
|
+
http://scoutapp.com/help#cron
|
47
|
+
|
48
|
+
END_SUCCESS
|
49
|
+
rescue SystemExit
|
50
|
+
puts <<-END_ERROR.gsub(/^ {10}/, "")
|
51
|
+
|
52
|
+
Could not contact server. The client key may be incorrect.
|
53
|
+
For more help, please visit:
|
54
|
+
|
55
|
+
http://scoutapp.com/help
|
56
|
+
|
57
|
+
END_ERROR
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|