overwatch 0.0.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.watchr +22 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +70 -0
- data/LICENSE.txt +20 -0
- data/README.md +29 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/overwatch +18 -0
- data/lib/overwatch.rb +106 -0
- data/lib/overwatch/client.rb +38 -0
- data/overwatch.gemspec +99 -0
- data/plugins/load_average.rb +8 -0
- data/plugins/mongodb.rb +113 -0
- data/plugins/mysql.rb +152 -0
- data/plugins/nginx.rb +0 -0
- data/plugins/redis.rb +52 -0
- data/spec/monitaur/client_spec.rb +57 -0
- data/spec/monitaur_spec.rb +68 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/bar_plugin.rb +8 -0
- data/spec/support/client_requests.rb +65 -0
- data/spec/support/foo_plugin.rb +8 -0
- data/spec/support/test.rb +3 -0
- metadata +215 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --drb --format doc
|
data/.watchr
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
def run_spec(file)
|
2
|
+
unless File.exist?(file)
|
3
|
+
puts "#{file} does not exist"
|
4
|
+
return
|
5
|
+
end
|
6
|
+
|
7
|
+
puts "Running #{file}"
|
8
|
+
system "bundle exec rspec #{file}"
|
9
|
+
puts
|
10
|
+
end
|
11
|
+
|
12
|
+
watch("spec/.*/*_spec\.rb") do |match|
|
13
|
+
run_spec match[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
watch("lib/(.*/.*)\.rb") do |match|
|
17
|
+
run_spec %{spec/#{match[1]}_spec.rb}
|
18
|
+
end
|
19
|
+
|
20
|
+
watch("lib/monitaur.rb") do |match|
|
21
|
+
run_spec %{spec/monitaur_spec.rb}
|
22
|
+
end
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'rest-client', '>= 1.6.3'
|
4
|
+
gem 'json', '>= 1.5.1'
|
5
|
+
gem 'ohai', '>= 0.6.4'
|
6
|
+
# gem 'SystemTimer', :require => 'system_timer'
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem "rspec", ">= 2.5.0"
|
10
|
+
gem "yard", ">= 0.6.0"
|
11
|
+
gem "bundler", ">= 1.0.0"
|
12
|
+
gem "jeweler", ">= 1.5.2"
|
13
|
+
gem "watchr"
|
14
|
+
gem 'spork', '>= 0.9.0.rc'
|
15
|
+
gem 'fuubar'
|
16
|
+
gem 'fakefs', :git => 'git://github.com/danryan/fakefs.git'
|
17
|
+
gem 'webmock'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/danryan/fakefs.git
|
3
|
+
revision: 95f4ef407909641218594c51002524a5cc72ab8b
|
4
|
+
specs:
|
5
|
+
fakefs (0.3.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.2.6)
|
11
|
+
crack (0.1.8)
|
12
|
+
diff-lcs (1.1.2)
|
13
|
+
fuubar (0.0.5)
|
14
|
+
rspec (~> 2.0)
|
15
|
+
rspec-instafail (~> 0.1.4)
|
16
|
+
ruby-progressbar (~> 0.0.10)
|
17
|
+
git (1.2.5)
|
18
|
+
jeweler (1.6.3)
|
19
|
+
bundler (~> 1.0)
|
20
|
+
git (>= 1.2.5)
|
21
|
+
rake
|
22
|
+
json (1.5.3)
|
23
|
+
mime-types (1.16)
|
24
|
+
mixlib-cli (1.2.0)
|
25
|
+
mixlib-config (1.1.2)
|
26
|
+
mixlib-log (1.3.0)
|
27
|
+
ohai (0.6.4)
|
28
|
+
mixlib-cli
|
29
|
+
mixlib-config
|
30
|
+
mixlib-log
|
31
|
+
systemu
|
32
|
+
yajl-ruby
|
33
|
+
rake (0.9.2)
|
34
|
+
rest-client (1.6.3)
|
35
|
+
mime-types (>= 1.16)
|
36
|
+
rspec (2.6.0)
|
37
|
+
rspec-core (~> 2.6.0)
|
38
|
+
rspec-expectations (~> 2.6.0)
|
39
|
+
rspec-mocks (~> 2.6.0)
|
40
|
+
rspec-core (2.6.4)
|
41
|
+
rspec-expectations (2.6.0)
|
42
|
+
diff-lcs (~> 1.1.2)
|
43
|
+
rspec-instafail (0.1.8)
|
44
|
+
rspec-mocks (2.6.0)
|
45
|
+
ruby-progressbar (0.0.10)
|
46
|
+
spork (0.9.0.rc9)
|
47
|
+
systemu (2.2.0)
|
48
|
+
watchr (0.7)
|
49
|
+
webmock (1.6.4)
|
50
|
+
addressable (~> 2.2, > 2.2.5)
|
51
|
+
crack (>= 0.1.7)
|
52
|
+
yajl-ruby (0.8.2)
|
53
|
+
yard (0.7.2)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (>= 1.0.0)
|
60
|
+
fakefs!
|
61
|
+
fuubar
|
62
|
+
jeweler (>= 1.5.2)
|
63
|
+
json (>= 1.5.1)
|
64
|
+
ohai (>= 0.6.4)
|
65
|
+
rest-client (>= 1.6.3)
|
66
|
+
rspec (>= 2.5.0)
|
67
|
+
spork (>= 0.9.0.rc)
|
68
|
+
watchr
|
69
|
+
webmock
|
70
|
+
yard (>= 0.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Dan Ryan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# overwatch-client
|
2
|
+
|
3
|
+
Client for the Overwatch monitoring service
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
The client is installed via rubygems
|
8
|
+
|
9
|
+
gem install overwatch
|
10
|
+
|
11
|
+
This creates the executable `overwatch`. Currently there is no daemon, so you can run it as a cron job:
|
12
|
+
|
13
|
+
* * * * * overwatch <api key>
|
14
|
+
|
15
|
+
## Plugins
|
16
|
+
|
17
|
+
Plugins are stored client-side for ease of deployment by your configuration management service. See the Plugin wiki for more info.
|
18
|
+
|
19
|
+
## Client run
|
20
|
+
|
21
|
+
* Client compiles the plugins and executes each, storing the result of each into a hash
|
22
|
+
* Client sends the resultant hash to the server for processing.
|
23
|
+
* That's it!
|
24
|
+
|
25
|
+
## Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2011 Dan Ryan. See LICENSE.txt for
|
28
|
+
further details.
|
29
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "overwatch"
|
16
|
+
gem.homepage = "http://github.com/danryan/overwatch-client"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Client for Overwatch monitoring service}
|
19
|
+
gem.description = %Q{The client to communicate with the Overwatch monitoring service}
|
20
|
+
gem.email = "hi@iamdanryan.com"
|
21
|
+
gem.authors = ["Dan Ryan"]
|
22
|
+
gem.executables = ["overwatch"]
|
23
|
+
|
24
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
25
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
26
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
27
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
31
|
+
require 'rspec/core'
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
34
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
38
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
39
|
+
spec.rcov = true
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'yard'
|
45
|
+
YARD::Rake::YardocTask.new
|
46
|
+
|
47
|
+
desc "Run watchr"
|
48
|
+
task :watchr do
|
49
|
+
sh %{bundle exec watchr .watchr}
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.3.pre
|
data/bin/overwatch
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. lib])
|
7
|
+
|
8
|
+
require 'overwatch'
|
9
|
+
require 'overwatch/client'
|
10
|
+
|
11
|
+
raise "You must supply an agent key as the first argument" unless ARGV[0]
|
12
|
+
api_key = ARGV[0]
|
13
|
+
|
14
|
+
begin
|
15
|
+
Overwatch.run api_key
|
16
|
+
rescue => e
|
17
|
+
puts e
|
18
|
+
end
|
data/lib/overwatch.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'yajl'
|
5
|
+
|
6
|
+
require 'overwatch/client'
|
7
|
+
|
8
|
+
module Overwatch
|
9
|
+
VERSION = IO.read(File.join(File.dirname(File.expand_path(__FILE__)), "../VERSION"))
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :log_file_path, :config_dir, :raw_config,
|
13
|
+
:config_file_path, :env, :cache_dir
|
14
|
+
|
15
|
+
def run(api_key)
|
16
|
+
# Overwatch.install
|
17
|
+
Overwatch::Client.new(api_key).run
|
18
|
+
end
|
19
|
+
|
20
|
+
# def install
|
21
|
+
# create_base_dir
|
22
|
+
# create_log_file
|
23
|
+
# create_cache_dir
|
24
|
+
# create_plugin_dir
|
25
|
+
# create_config_dir
|
26
|
+
# generate_client_config unless File.exist?(config_file_path)
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# def env=(environment)
|
30
|
+
# @env = environment
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def env
|
34
|
+
# @env ||= "production"
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# def base_dir
|
38
|
+
# @base_dir ||= "#{ENV['HOME']}/.overwatch"
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# def log
|
42
|
+
# @log ||= Logger.new(log_file_path)
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def log_file_path
|
46
|
+
# @log_file_path ||= File.join(base_dir, "client.log")
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# def config_dir
|
50
|
+
# @config_dir ||= File.join(base_dir, "")
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# def cache_dir
|
54
|
+
# @cache_dir ||= File.join(base_dir, "cache")
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# def plugin_dir
|
58
|
+
# @plugin_dir ||= File.join(cache_dir, "plugins")
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
|
62
|
+
def plugin_path
|
63
|
+
@plugin_path ||= File.expand_path(File.join(File.dirname(__FILE__), "../plugins"))
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# def config_file_path
|
68
|
+
# @config_file_path ||= File.join(base_dir, "config.yml")
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# def raw_config
|
72
|
+
# @raw_config ||= IO.read(config_file_path)
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# def create_log_file
|
76
|
+
# FileUtils.touch(log_file_path)
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# def create_base_dir
|
80
|
+
# FileUtils.mkdir_p(base_dir)
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# def create_config_dir
|
84
|
+
# FileUtils.mkdir_p(config_dir)
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# def create_cache_dir
|
88
|
+
# FileUtils.mkdir_p(cache_dir)
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# def create_plugin_dir
|
92
|
+
# FileUtils.mkdir_p(plugin_dir)
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# def generate_client_config
|
96
|
+
# File.open(config_file_path, "w") do |file|
|
97
|
+
# file.puts(%q{server_url: http://api.overwatchapp.com})
|
98
|
+
# file.puts(%q{client_key: CHANGEME})
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# def raw_config
|
103
|
+
# @raw_config ||= IO.read(config_file_path)
|
104
|
+
# end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'overwatch/mixin'
|
2
|
+
require 'yaml'
|
3
|
+
require 'ohai'
|
4
|
+
|
5
|
+
module Overwatch
|
6
|
+
class Client
|
7
|
+
attr_accessor :logger, :server_url, :config, :raw_config,
|
8
|
+
:plugin_manifest, :api_key, :data
|
9
|
+
|
10
|
+
def initialize(api_key)
|
11
|
+
@ohai = Ohai::System.new
|
12
|
+
@api_key = api_key
|
13
|
+
Ohai::Config[:plugin_path] << Overwatch.plugin_path unless Ohai::Config[:plugin_path].include?(Overwatch.plugin_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
all_plugins
|
18
|
+
post_data
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_plugins
|
22
|
+
@ohai.all_plugins
|
23
|
+
end
|
24
|
+
|
25
|
+
def post_data
|
26
|
+
res = RestClient.post(
|
27
|
+
"http://overwat.ch:9292/nodes/#{api_key}",
|
28
|
+
Yajl.dump(data),
|
29
|
+
{ 'Content-Type' => 'application/json' }
|
30
|
+
)
|
31
|
+
puts res.body
|
32
|
+
end
|
33
|
+
|
34
|
+
def data
|
35
|
+
@ohai.data
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/overwatch.gemspec
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{overwatch}
|
8
|
+
s.version = "0.0.3.pre"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dan Ryan"]
|
12
|
+
s.date = %q{2011-07-01}
|
13
|
+
s.default_executable = %q{overwatch}
|
14
|
+
s.description = %q{The client to communicate with the Overwatch monitoring service}
|
15
|
+
s.email = %q{hi@iamdanryan.com}
|
16
|
+
s.executables = ["overwatch"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
".watchr",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/overwatch",
|
32
|
+
"lib/overwatch.rb",
|
33
|
+
"lib/overwatch/client.rb",
|
34
|
+
"overwatch.gemspec",
|
35
|
+
"plugins/load_average.rb",
|
36
|
+
"plugins/mongodb.rb",
|
37
|
+
"plugins/mysql.rb",
|
38
|
+
"plugins/nginx.rb",
|
39
|
+
"plugins/redis.rb",
|
40
|
+
"spec/monitaur/client_spec.rb",
|
41
|
+
"spec/monitaur_spec.rb",
|
42
|
+
"spec/spec_helper.rb",
|
43
|
+
"spec/support/bar_plugin.rb",
|
44
|
+
"spec/support/client_requests.rb",
|
45
|
+
"spec/support/foo_plugin.rb",
|
46
|
+
"spec/support/test.rb"
|
47
|
+
]
|
48
|
+
s.homepage = %q{http://github.com/danryan/overwatch-client}
|
49
|
+
s.licenses = ["MIT"]
|
50
|
+
s.require_paths = ["lib"]
|
51
|
+
s.rubygems_version = %q{1.6.2}
|
52
|
+
s.summary = %q{Client for Overwatch monitoring service}
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 1.6.3"])
|
59
|
+
s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
|
60
|
+
s.add_runtime_dependency(%q<ohai>, [">= 0.6.4"])
|
61
|
+
s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
|
62
|
+
s.add_development_dependency(%q<yard>, [">= 0.6.0"])
|
63
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
|
65
|
+
s.add_development_dependency(%q<watchr>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<spork>, [">= 0.9.0.rc"])
|
67
|
+
s.add_development_dependency(%q<fuubar>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<fakefs>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<rest-client>, [">= 1.6.3"])
|
72
|
+
s.add_dependency(%q<json>, [">= 1.5.1"])
|
73
|
+
s.add_dependency(%q<ohai>, [">= 0.6.4"])
|
74
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
75
|
+
s.add_dependency(%q<yard>, [">= 0.6.0"])
|
76
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
78
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
79
|
+
s.add_dependency(%q<spork>, [">= 0.9.0.rc"])
|
80
|
+
s.add_dependency(%q<fuubar>, [">= 0"])
|
81
|
+
s.add_dependency(%q<fakefs>, [">= 0"])
|
82
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
83
|
+
end
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<rest-client>, [">= 1.6.3"])
|
86
|
+
s.add_dependency(%q<json>, [">= 1.5.1"])
|
87
|
+
s.add_dependency(%q<ohai>, [">= 0.6.4"])
|
88
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
89
|
+
s.add_dependency(%q<yard>, [">= 0.6.0"])
|
90
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
91
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
92
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
93
|
+
s.add_dependency(%q<spork>, [">= 0.9.0.rc"])
|
94
|
+
s.add_dependency(%q<fuubar>, [">= 0"])
|
95
|
+
s.add_dependency(%q<fakefs>, [">= 0"])
|
96
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
provides "load_average"
|
2
|
+
load_average Mash.new
|
3
|
+
|
4
|
+
raw_load_averages = %x[uptime|cut -d: -f4].strip.split(" ")
|
5
|
+
|
6
|
+
load_average[:one_minute] = raw_load_averages[0]
|
7
|
+
load_average[:five_minutes] = raw_load_averages[1]
|
8
|
+
load_average[:fifteen_minutes] = raw_load_averages[2]
|
data/plugins/mongodb.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
provides "mongo"
|
2
|
+
mongo Mash.new
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'mongo'
|
6
|
+
rescue LoadError => e
|
7
|
+
Ohai::Log.warn e.message
|
8
|
+
end
|
9
|
+
|
10
|
+
connection = Mongo::Connection.new
|
11
|
+
server_stats = connection.db("local").command('serverStatus' => 1)
|
12
|
+
|
13
|
+
mongo[:version] = server_stats['version']
|
14
|
+
mongo[:uptime] = server_stats['uptime']
|
15
|
+
mongo[:host] = server_stats['host']
|
16
|
+
mongo[:uptime_estimate] = server_stats['uptimeEstimate']
|
17
|
+
|
18
|
+
# DB stats
|
19
|
+
mongo[:databases] = {}
|
20
|
+
connection.database_names.map(&:to_sym).each do |db_name|
|
21
|
+
stats = connection.db(db_name).stats
|
22
|
+
mongo[:databases][db_name] = Mash.new
|
23
|
+
mongo[:databases][db_name][:collections] = stats['collections']
|
24
|
+
mongo[:databases][db_name][:objects] = stats['objects']
|
25
|
+
mongo[:databases][db_name][:indexes] = stats['indexes']
|
26
|
+
mongo[:databases][db_name][:data_size] = stats['dataSize']
|
27
|
+
mongo[:databases][db_name][:storage_size] = stats['storageSize']
|
28
|
+
mongo[:databases][db_name][:file_size] = stats['fileSize']
|
29
|
+
mongo[:databases][db_name][:avg_obj_size] = stats['avgObjSize']
|
30
|
+
mongo[:databases][db_name][:index_size] = stats['indexSize']
|
31
|
+
mongo[:databases][db_name][:num_extents] = stats['numExtents']
|
32
|
+
end
|
33
|
+
|
34
|
+
# Connections
|
35
|
+
mongo[:connections] = Mash.new
|
36
|
+
mongo[:connections][:current] = server_stats['connections']['current']
|
37
|
+
mongo[:connections][:available] = server_stats['connections']['available']
|
38
|
+
|
39
|
+
# Memory usage
|
40
|
+
mongo[:memory] = Mash.new
|
41
|
+
mongo[:memory][:resident] = server_stats['mem']['resident']
|
42
|
+
mongo[:memory][:virtual] = server_stats['mem']['virtual']
|
43
|
+
mongo[:memory][:supported] = server_stats['mem']['supported']
|
44
|
+
mongo[:memory][:mapped] = server_stats['mem']['mapped']
|
45
|
+
|
46
|
+
# Global lock
|
47
|
+
mongo[:global_lock] = Mash.new
|
48
|
+
mongo[:global_lock][:ratio] = server_stats['globalLock']['ratio']
|
49
|
+
mongo[:global_lock][:current_queue] = Mash.new
|
50
|
+
mongo[:global_lock][:current_queue][:total] = server_stats['globalLock']['currentQueue']['total']
|
51
|
+
mongo[:global_lock][:current_queue][:readers] = server_stats['globalLock']['currentQueue']['readers']
|
52
|
+
mongo[:global_lock][:current_queue][:writers] = server_stats['globalLock']['currentQueue']['writers']
|
53
|
+
mongo[:global_lock][:active_clients] = Mash.new
|
54
|
+
mongo[:global_lock][:active_clients][:total] = server_stats['globalLock']['activeClients']['total']
|
55
|
+
mongo[:global_lock][:active_clients][:readers] = server_stats['globalLock']['activeClients']['readers']
|
56
|
+
mongo[:global_lock][:active_clients][:writers] = server_stats['globalLock']['activeClients']['writers']
|
57
|
+
|
58
|
+
|
59
|
+
# Index counters
|
60
|
+
mongo[:index_counters] = Mash.new
|
61
|
+
mongo[:index_counters][:accesses] = server_stats['indexCounters']['btree']['accesses']
|
62
|
+
mongo[:index_counters][:hits] = server_stats['indexCounters']['btree']['hits']
|
63
|
+
mongo[:index_counters][:misses] = server_stats['indexCounters']['btree']['misses']
|
64
|
+
mongo[:index_counters][:resets] = server_stats['indexCounters']['btree']['resets']
|
65
|
+
mongo[:index_counters][:miss_ratio] = server_stats['indexCounters']['btree']['missRatio']
|
66
|
+
|
67
|
+
# Background flushing
|
68
|
+
mongo[:background_flushing] = Mash.new
|
69
|
+
mongo[:background_flushing][:flushes] = server_stats['backgroundFlushing']['flushes']
|
70
|
+
mongo[:background_flushing][:total_ms] = server_stats['backgroundFlushing']['average_ms']
|
71
|
+
mongo[:background_flushing][:last_ms] = server_stats['backgroundFlushing']['last_ms']
|
72
|
+
mongo[:background_flushing][:last_finished] = server_stats['backgroundFlushing']['last_finished'].to_s
|
73
|
+
|
74
|
+
# Op counters
|
75
|
+
mongo[:op_counters] = Mash.new
|
76
|
+
mongo[:op_counters][:insert] = server_stats['opcounters']['insert']
|
77
|
+
mongo[:op_counters][:query] = server_stats['opcounters']['query']
|
78
|
+
mongo[:op_counters][:update] = server_stats['opcounters']['update']
|
79
|
+
mongo[:op_counters][:delete] = server_stats['opcounters']['delete']
|
80
|
+
mongo[:op_counters][:getmore] = server_stats['opcounters']['getmore']
|
81
|
+
mongo[:op_counters][:command] = server_stats['opcounters']['command']
|
82
|
+
|
83
|
+
# Asserts
|
84
|
+
mongo[:asserts] = Mash.new
|
85
|
+
mongo[:asserts][:regular] = server_stats['asserts']['regular']
|
86
|
+
mongo[:asserts][:warning] = server_stats['asserts']['warning']
|
87
|
+
mongo[:asserts][:msg] = server_stats['asserts']['msg']
|
88
|
+
mongo[:asserts][:user] = server_stats['asserts']['user']
|
89
|
+
mongo[:asserts][:rollovers] = server_stats['asserts']['rollovers']
|
90
|
+
|
91
|
+
# Network
|
92
|
+
mongo[:network] = Mash.new
|
93
|
+
mongo[:network][:bytes_in] = server_stats['network']['bytesIn']
|
94
|
+
mongo[:network][:bytes_out] = server_stats['network']['bytesOut']
|
95
|
+
mongo[:network][:num_requests] = server_stats['network']['numRequests']
|
96
|
+
|
97
|
+
# Replica Set
|
98
|
+
|
99
|
+
begin
|
100
|
+
admin = connection.db("admin")
|
101
|
+
repl_stats = admin.command('replSetGetStatus' => 1)
|
102
|
+
rescue Mongo::OperationFailure => e
|
103
|
+
Ohai::Log.warn e.message
|
104
|
+
end
|
105
|
+
|
106
|
+
mongo[:repl_set] = Mash.new
|
107
|
+
mongo[:repl_set][:set] = repl_set['set']
|
108
|
+
mongo[:repl_set][:date] = repl_set['date']
|
109
|
+
mongo[:repl_set][:my_state] = repl_set['myState']
|
110
|
+
mongo[:repl_set][:members] = []
|
111
|
+
repl_set['members'].each do |member|
|
112
|
+
mongo[:repl_set][:members] << member.symbolize_keys
|
113
|
+
end
|
data/plugins/mysql.rb
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
provides "mysql"
|
2
|
+
mysql Mash.new
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'mysql'
|
6
|
+
rescue LoadError => e
|
7
|
+
Ohai::Log.warn e.message
|
8
|
+
end
|
9
|
+
|
10
|
+
user = nil
|
11
|
+
passwd = nil
|
12
|
+
port = nil
|
13
|
+
connection = Mysql.connect("localhost", user, passwd, nil, port )
|
14
|
+
|
15
|
+
global_status = Mash.new
|
16
|
+
|
17
|
+
raw_status = connection.query("SHOW GLOBAL STATUS")
|
18
|
+
raw_status.each do |row|
|
19
|
+
global_status[row.first] = row.last.to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
variables = Mash.new
|
23
|
+
|
24
|
+
raw_variables = connection.query("SHOW VARIABLES")
|
25
|
+
raw_variables.each do |row|
|
26
|
+
variables[row.first] = row.last.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
mysql[:max_used_connections] = global_status['Max_used_connections']
|
30
|
+
mysql[:connections] = global_status['Connections']
|
31
|
+
mysql[:slow_queries] = global_status['Slow_queries']
|
32
|
+
|
33
|
+
# Threads
|
34
|
+
mysql[:threads_cached] = global_status['Threads_cached']
|
35
|
+
mysql[:threads_connected] = global_status['Threads_connected']
|
36
|
+
mysql[:threads_created] = global_status['Threads_created']
|
37
|
+
mysql[:threads_running] = global_status['Threads_running']
|
38
|
+
|
39
|
+
# Errors
|
40
|
+
mysql[:aborted_clients] = global_status['Aborted_clients']
|
41
|
+
mysql[:aborted_connects] = global_status['Aborted_connects']
|
42
|
+
|
43
|
+
# Network
|
44
|
+
|
45
|
+
mysql[:bytes_received] = global_status['Bytes_received']
|
46
|
+
mysql[:bytes_sent] = global_status['Bytes_sent']
|
47
|
+
|
48
|
+
# Temp tables
|
49
|
+
|
50
|
+
mysql[:created_tmp_disk_tables] = global_status["Created_tmp_disk_tables"]
|
51
|
+
mysql[:created_tmp_files] = global_status["Created_tmp_files"]
|
52
|
+
mysql[:created_tmp_tables] = global_status["Created_tmp_tables"]
|
53
|
+
|
54
|
+
mysql[:table_locks_waited] = global_status["Table_locks_waited"]
|
55
|
+
|
56
|
+
# InnoDB
|
57
|
+
|
58
|
+
mysql[:innodb_buffer_pool_pages_data] = global_status["Innodb_buffer_pool_pages_dirty"]
|
59
|
+
mysql[:innodb_buffer_pool_pages_dirty] = global_status["Innodb_buffer_pool_pages_flushed"]
|
60
|
+
mysql[:innodb_buffer_pool_pages_flushed] = global_status["Innodb_buffer_pool_pages_free"]
|
61
|
+
mysql[:innodb_buffer_pool_pages_free] = global_status["Innodb_buffer_pool_pages_misc"]
|
62
|
+
mysql[:innodb_buffer_pool_pages_misc] = global_status["Innodb_buffer_pool_pages_total"]
|
63
|
+
mysql[:innodb_buffer_pool_pages_total] = global_status["Innodb_buffer_pool_read_ahead"]
|
64
|
+
mysql[:innodb_buffer_pool_read_ahead] = global_status["Innodb_buffer_pool_read_ahead_evicted"]
|
65
|
+
mysql[:innodb_buffer_pool_read_ahead_evicted] = global_status["Innodb_buffer_pool_read_requests"]
|
66
|
+
mysql[:innodb_buffer_pool_read_requests] = global_status["Innodb_buffer_pool_reads"]
|
67
|
+
mysql[:innodb_buffer_pool_reads] = global_status["Innodb_buffer_pool_wait_free"]
|
68
|
+
mysql[:innodb_buffer_pool_wait_free] = global_status["Innodb_buffer_pool_write_requests"]
|
69
|
+
mysql[:innodb_buffer_pool_write_requests] = global_status["Innodb_data_fsyncs"]
|
70
|
+
mysql[:innodb_data_fsyncs] = global_status["Innodb_data_pending_fsyncs"]
|
71
|
+
mysql[:innodb_data_pending_fsyncs] = global_status["Innodb_data_pending_reads"]
|
72
|
+
mysql[:innodb_data_pending_reads] = global_status["Innodb_data_pending_writes"]
|
73
|
+
mysql[:innodb_data_pending_writes] = global_status["Innodb_data_read"]
|
74
|
+
mysql[:innodb_data_read] = global_status["Innodb_data_reads"]
|
75
|
+
mysql[:innodb_data_reads] = global_status["Innodb_data_writes"]
|
76
|
+
mysql[:innodb_data_writes] = global_status["Innodb_data_written"]
|
77
|
+
mysql[:innodb_data_written] = global_status["Innodb_dblwr_pages_written"]
|
78
|
+
mysql[:innodb_dblwr_pages_written] = global_status["Innodb_dblwr_writes"]
|
79
|
+
mysql[:innodb_dblwr_writes] = global_status["Innodb_have_atomic_builtins"]
|
80
|
+
mysql[:innodb_have_atomic_builtins] = global_status["Innodb_log_waits"]
|
81
|
+
mysql[:innodb_log_waits] = global_status["Innodb_log_write_requests"]
|
82
|
+
mysql[:innodb_log_write_requests] = global_status["Innodb_log_writes"]
|
83
|
+
mysql[:innodb_log_writes] = global_status["Innodb_os_log_fsyncs"]
|
84
|
+
mysql[:innodb_os_log_fsyncs] = global_status["Innodb_os_log_pending_fsyncs"]
|
85
|
+
mysql[:innodb_os_log_pending_fsyncs] = global_status["Innodb_os_log_pending_writes"]
|
86
|
+
mysql[:innodb_os_log_pending_writes] = global_status["Innodb_os_log_written"]
|
87
|
+
mysql[:innodb_os_log_written] = global_status["Innodb_page_size"]
|
88
|
+
mysql[:innodb_page_size] = global_status["Innodb_pages_created"]
|
89
|
+
mysql[:innodb_pages_created] = global_status["Innodb_pages_read"]
|
90
|
+
mysql[:innodb_pages_read] = global_status["Innodb_pages_written"]
|
91
|
+
mysql[:innodb_pages_written] = global_status["Innodb_row_lock_current_waits"]
|
92
|
+
mysql[:innodb_row_lock_current_waits] = global_status["Innodb_row_lock_time"]
|
93
|
+
mysql[:innodb_row_lock_time] = global_status["Innodb_row_lock_time_avg"]
|
94
|
+
mysql[:innodb_row_lock_time_avg] = global_status["Innodb_row_lock_time_max"]
|
95
|
+
mysql[:innodb_row_lock_time_max] = global_status["Innodb_row_lock_waits"]
|
96
|
+
mysql[:innodb_row_lock_waits] = global_status["Innodb_rows_deleted"]
|
97
|
+
mysql[:innodb_rows_deleted] = global_status["Innodb_rows_inserted"]
|
98
|
+
mysql[:innodb_rows_inserted] = global_status["Innodb_rows_read"]
|
99
|
+
mysql[:innodb_rows_read] = global_status["Innodb_rows_updated"]
|
100
|
+
mysql[:innodb_rows_updated] = global_status["Innodb_truncated_status_writes"]
|
101
|
+
mysql[:innodb_truncated_status_writes] = global_status["Innodb_buffer_pool_pages_data"]
|
102
|
+
|
103
|
+
# Qcache
|
104
|
+
mysql[:qcache_free_blocks] = global_status["Qcache_free_blocks"]
|
105
|
+
mysql[:qcache_free_memory] = global_status["Qcache_free_memory"]
|
106
|
+
mysql[:qcache_hits] = global_status["Qcache_hits"]
|
107
|
+
mysql[:qcache_inserts] = global_status["Qcache_inserts"]
|
108
|
+
mysql[:qcache_lowmem_prunes] = global_status["Qcache_lowmem_prunes"]
|
109
|
+
mysql[:qcache_not_cached] = global_status["Qcache_not_cached"]
|
110
|
+
mysql[:qcache_queries_in_cache] = global_status["Qcache_queries_in_cache"]
|
111
|
+
mysql[:qcache_total_blocks] = global_status["Qcache_total_blocks"]
|
112
|
+
|
113
|
+
# Keys
|
114
|
+
mysql[:key_blocks_not_flushed] = global_status["Key_blocks_not_flushed"]
|
115
|
+
mysql[:key_blocks_unused] = global_status["Key_blocks_unused"]
|
116
|
+
mysql[:key_blocks_used] = global_status["Key_blocks_used"]
|
117
|
+
mysql[:key_read_requests] = global_status["Key_read_requests"]
|
118
|
+
mysql[:key_reads] = global_status["Key_reads"]
|
119
|
+
mysql[:key_write_requests] = global_status["Key_write_requests"]
|
120
|
+
mysql[:key_writes] = global_status["Key_writes"]
|
121
|
+
|
122
|
+
## VARIABLES
|
123
|
+
|
124
|
+
# Binlog
|
125
|
+
mysql[:binlog_cache_size] = variables["binlog_cache_size"]
|
126
|
+
mysql[:binlog_direct_non_transactional_updates] = variables["binlog_direct_non_transactional_updates"]
|
127
|
+
mysql[:binlog_format] = variables["binlog_format"]
|
128
|
+
mysql[:binlog_stmt_cache_size] = variables["binlog_stmt_cache_size"]
|
129
|
+
|
130
|
+
# Max
|
131
|
+
|
132
|
+
mysql[:max_allowed_packet] = variables["max_allowed_packet"]
|
133
|
+
mysql[:max_binlog_cache_size] = variables["max_binlog_cache_size"]
|
134
|
+
mysql[:max_binlog_size] = variables["max_binlog_size"]
|
135
|
+
mysql[:max_binlog_stmt_cache_size] = variables["max_binlog_stmt_cache_size"]
|
136
|
+
mysql[:max_connect_errors] = variables["max_connect_errors"]
|
137
|
+
mysql[:max_connections] = variables["max_connections"]
|
138
|
+
mysql[:max_delayed_threads] = variables["max_delayed_threads"]
|
139
|
+
mysql[:max_error_count] = variables["max_error_count"]
|
140
|
+
mysql[:max_heap_table_size] = variables["max_heap_table_size"]
|
141
|
+
mysql[:max_insert_delayed_threads] = variables["max_insert_delayed_threads"]
|
142
|
+
mysql[:max_join_size] = variables["max_join_size"]
|
143
|
+
mysql[:max_length_for_sort_data] = variables["max_length_for_sort_data"]
|
144
|
+
mysql[:max_long_data_size] = variables["max_long_data_size"]
|
145
|
+
mysql[:max_prepared_stmt_count] = variables["max_prepared_stmt_count"]
|
146
|
+
mysql[:max_relay_log_size] = variables["max_relay_log_size"]
|
147
|
+
mysql[:max_seeks_for_key] = variables["max_seeks_for_key"]
|
148
|
+
mysql[:max_sort_length] = variables["max_sort_length"]
|
149
|
+
mysql[:max_sp_recursion_depth] = variables["max_sp_recursion_depth"]
|
150
|
+
mysql[:max_tmp_tables] = variables["max_tmp_tables"]
|
151
|
+
mysql[:max_user_connections] = variables["max_user_connections"]
|
152
|
+
mysql[:max_write_lock_count] = variables["max_write_lock_count"]
|
data/plugins/nginx.rb
ADDED
File without changes
|
data/plugins/redis.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
provides "redis"
|
2
|
+
redis Mash.new
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'redis'
|
6
|
+
require 'system_timer'
|
7
|
+
rescue LoadError => e
|
8
|
+
Ohai::Log.warn e.message
|
9
|
+
end
|
10
|
+
|
11
|
+
port = 6379
|
12
|
+
info = Mash.new(Redis.new(:port => port).info).symbolize_keys
|
13
|
+
|
14
|
+
redis[:version] = info[:redis_version]
|
15
|
+
redis[:arch_bits] = info[:arch_bits]
|
16
|
+
redis[:multiplexing_api] = info[:multiplexing_api]
|
17
|
+
redis[:process_id] = info[:process_id]
|
18
|
+
redis[:uptime_in_seconds] = info[:uptime_in_seconds]
|
19
|
+
redis[:uptime_in_days] = info[:uptime_in_days]
|
20
|
+
redis[:lru_clock] = info[:lru_clock]
|
21
|
+
redis[:used_cpu_sys] = info[:used_cpu_sys]
|
22
|
+
redis[:used_cpu_user] = info[:used_cpu_user]
|
23
|
+
redis[:used_cpu_sys_childrens] = info[:used_cpu_sys_childrens]
|
24
|
+
redis[:used_cpu_user_childrens] = info[:used_cpu_user_childrens]
|
25
|
+
redis[:connected_clients] = info[:connected_clients]
|
26
|
+
redis[:connected_slaves] = info[:connected_slaves]
|
27
|
+
redis[:client_longest_output_list] = info[:client_longest_output_list]
|
28
|
+
redis[:client_biggest_input_buf] = info[:client_biggest_input_buf]
|
29
|
+
redis[:blocked_clients] = info[:blocked_clients]
|
30
|
+
redis[:used_memory] = info[:used_memory]
|
31
|
+
redis[:used_memory_human] = info[:used_memory_human]
|
32
|
+
redis[:used_memory_rss] = info[:used_memory_rss]
|
33
|
+
redis[:mem_fragmentation_ratio] = info[:mem_fragmentation_ratio]
|
34
|
+
redis[:use_tcmalloc] = info[:use_tcmalloc]
|
35
|
+
redis[:loading] = info[:loading]
|
36
|
+
redis[:aof_enabled] = info[:aof_enabled]
|
37
|
+
redis[:changes_since_last_save] = info[:changes_since_last_save]
|
38
|
+
redis[:bgsave_in_progress] = info[:bgsave_in_progress]
|
39
|
+
redis[:last_save_time] = info[:last_save_time]
|
40
|
+
redis[:bgrewriteaof_in_progress] = info[:bgrewriteaof_in_progress]
|
41
|
+
redis[:total_connections_received] = info[:total_connections_received]
|
42
|
+
redis[:total_commands_processed] = info[:total_commands_processed]
|
43
|
+
redis[:expired_keys] = info[:expired_keys]
|
44
|
+
redis[:evicted_keys] = info[:evicted_keys]
|
45
|
+
redis[:keyspace_hits] = info[:keyspace_hits]
|
46
|
+
redis[:keyspace_misses] = info[:keyspace_misses]
|
47
|
+
redis[:hash_max_zipmap_entries] = info[:hash_max_zipmap_entries]
|
48
|
+
redis[:hash_max_zipmap_value] = info[:hash_max_zipmap_value]
|
49
|
+
redis[:pubsub_channels] = info[:pubsub_channels]
|
50
|
+
redis[:pubsub_patterns] = info[:pubsub_patterns]
|
51
|
+
redis[:vm_enabled] = info[:vm_enabled]
|
52
|
+
redis[:role] = info[:role]
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Overwatch
|
4
|
+
describe Client do
|
5
|
+
let(:server_url) { "http://api.overwatchapp.com" }
|
6
|
+
let(:client_key) { "asdf1234" }
|
7
|
+
|
8
|
+
describe "#load_config" do
|
9
|
+
let(:client) { Overwatch::Client.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
File.open(Overwatch.config_file_path, "w") do |file|
|
13
|
+
file.puts "server_url: http://api.overwatchapp.com"
|
14
|
+
file.puts "client_key: asdf1234"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "loads up the configuration file" do
|
19
|
+
client.load_config
|
20
|
+
client.server_url.should == "http://api.overwatchapp.com"
|
21
|
+
client.client_key.should == "asdf1234"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#get_plugin_manifest" do
|
26
|
+
let(:client) { Overwatch::Client.new }
|
27
|
+
|
28
|
+
before do
|
29
|
+
stub_get_plugin_manifest
|
30
|
+
end
|
31
|
+
|
32
|
+
it "retrieves a plugins manifest from the server" do
|
33
|
+
client.get_plugin_manifest
|
34
|
+
client.plugin_manifest.should == plugin_manifest_response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#sync_plugins" do
|
39
|
+
let(:client) { Overwatch::Client.new }
|
40
|
+
|
41
|
+
before do
|
42
|
+
Overwatch.install
|
43
|
+
stub_get_plugin_manifest
|
44
|
+
stub_sync_plugins
|
45
|
+
client.get_plugin_manifest
|
46
|
+
end
|
47
|
+
|
48
|
+
it "downloads plugins to the cache directory" do
|
49
|
+
client.sync_plugins
|
50
|
+
File.exist?(File.join(Overwatch.plugin_dir, "foo_plugin.rb")).should be_true
|
51
|
+
File.exist?(File.join(Overwatch.plugin_dir, "bar_plugin.rb")).should be_true
|
52
|
+
File.open(File.join(Overwatch.plugin_dir, "bar_plugin.rb")).read.should include("class BarPlugin")
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Overwatch do
|
4
|
+
before do
|
5
|
+
ENV['HOME'] = "/home/user"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.run' do
|
9
|
+
let(:config_file) { mock('config_file') }
|
10
|
+
|
11
|
+
before do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "creates the required application files" do
|
15
|
+
FileUtils.should_receive(:mkdir_p).with(Overwatch.base_dir)
|
16
|
+
FileUtils.should_receive(:touch).with(Overwatch.log_file_path)
|
17
|
+
FileUtils.should_receive(:mkdir_p).with(Overwatch.cache_dir)
|
18
|
+
FileUtils.should_receive(:mkdir_p).with(Overwatch.plugin_dir)
|
19
|
+
FileUtils.should_receive(:mkdir_p).with(Overwatch.config_dir)
|
20
|
+
|
21
|
+
File.should_receive(:open).
|
22
|
+
with(Overwatch.config_file_path, "w").
|
23
|
+
and_yield(config_file)
|
24
|
+
config_file.should_receive(:puts).
|
25
|
+
with('server_url: http://api.overwatchapp.com')
|
26
|
+
config_file.should_receive(:puts).
|
27
|
+
with('client_key: CHANGEME')
|
28
|
+
Overwatch.install
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "logging" do
|
33
|
+
describe '.log_file_path' do
|
34
|
+
it "returns '/home/user/.overwatch/client.log'" do
|
35
|
+
Overwatch.log_file_path.should == "/home/user/.overwatch/client.log"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '.log_file_path=' do
|
40
|
+
it "sets @log_file_path" do
|
41
|
+
Overwatch.log_file_path = "/tmp/something.log"
|
42
|
+
Overwatch.log_file_path.should == "/tmp/something.log"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.log' do
|
47
|
+
it "functions as a logger" do
|
48
|
+
Overwatch.log.should be_an_instance_of(Logger)
|
49
|
+
lambda { Overwatch.log.info "TEST" }.should_not raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "environment" do
|
55
|
+
describe '.env=' do
|
56
|
+
it "sets the @env variable" do
|
57
|
+
Overwatch.env = "pants"
|
58
|
+
Overwatch.env.should == "pants"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.env' do
|
63
|
+
it "returns 'test' inside specs" do
|
64
|
+
Overwatch.env.should == "test"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'bundler'
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
|
11
|
+
require 'rspec'
|
12
|
+
require 'fakefs/safe'
|
13
|
+
require 'webmock/rspec'
|
14
|
+
|
15
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.before do
|
19
|
+
FakeFS.activate!
|
20
|
+
end
|
21
|
+
config.after do
|
22
|
+
FakeFS.deactivate!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Spork.each_run do
|
28
|
+
require 'overwatch'
|
29
|
+
|
30
|
+
RSpec.configure do |config|
|
31
|
+
config.before do
|
32
|
+
ENV['HOME'] = "/home/user"
|
33
|
+
|
34
|
+
Overwatch.env = "test"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
def stub_get_plugin_manifest
|
2
|
+
stub_request(:get, "#{server_url}/nodes/#{client_key}/plugins").
|
3
|
+
to_return(
|
4
|
+
:status => 200,
|
5
|
+
:body => %Q{
|
6
|
+
[
|
7
|
+
{
|
8
|
+
"name": "foo_plugin",
|
9
|
+
"checksum": "qwer5678"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"name": "bar_plugin",
|
13
|
+
"checksum": "hjkl4321"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def plugin_manifest_response
|
21
|
+
[
|
22
|
+
{
|
23
|
+
"name" => "foo_plugin",
|
24
|
+
"checksum" => "qwer5678"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name" => "bar_plugin",
|
28
|
+
"checksum" => "hjkl4321"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def stub_sync_plugins
|
34
|
+
stub_request(:get, "#{server_url}/plugins/foo_plugin").
|
35
|
+
to_return(:body => stub_foo_plugin)
|
36
|
+
|
37
|
+
stub_request(:get, "#{server_url}/plugins/bar_plugin").
|
38
|
+
to_return(:body => stub_bar_plugin)
|
39
|
+
end
|
40
|
+
|
41
|
+
def stub_foo_plugin
|
42
|
+
%|
|
43
|
+
class FooPlugin < Overwatch::Plugin
|
44
|
+
name "foo_plugin"
|
45
|
+
desc "A test plugin to determine whether plugin sync works"
|
46
|
+
|
47
|
+
def run
|
48
|
+
{ :foo => 'foo' }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
|
52
|
+
end
|
53
|
+
|
54
|
+
def stub_bar_plugin
|
55
|
+
%|
|
56
|
+
class BarPlugin < Overwatch::Plugin
|
57
|
+
name "bar_plugin"
|
58
|
+
desc "A test plugin to determine whether plugin sync works"
|
59
|
+
|
60
|
+
def run
|
61
|
+
{ :bar => 'bar' }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: overwatch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.0.3.pre
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Ryan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-01 00:00:00 -04:00
|
14
|
+
default_executable: overwatch
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rest-client
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.6.3
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.5.1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: ohai
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.6.4
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.5.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: yard
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.6.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: bundler
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.0.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: jeweler
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.5.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: watchr
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
type: :development
|
102
|
+
prerelease: false
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: spork
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.9.0.rc
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: fuubar
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: "0"
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id010
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: fakefs
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: "0"
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: *id011
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: webmock
|
139
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: "0"
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *id012
|
148
|
+
description: The client to communicate with the Overwatch monitoring service
|
149
|
+
email: hi@iamdanryan.com
|
150
|
+
executables:
|
151
|
+
- overwatch
|
152
|
+
extensions: []
|
153
|
+
|
154
|
+
extra_rdoc_files:
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
files:
|
158
|
+
- .document
|
159
|
+
- .rspec
|
160
|
+
- .watchr
|
161
|
+
- Gemfile
|
162
|
+
- Gemfile.lock
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.md
|
165
|
+
- Rakefile
|
166
|
+
- VERSION
|
167
|
+
- bin/overwatch
|
168
|
+
- lib/overwatch.rb
|
169
|
+
- lib/overwatch/client.rb
|
170
|
+
- overwatch.gemspec
|
171
|
+
- plugins/load_average.rb
|
172
|
+
- plugins/mongodb.rb
|
173
|
+
- plugins/mysql.rb
|
174
|
+
- plugins/nginx.rb
|
175
|
+
- plugins/redis.rb
|
176
|
+
- spec/monitaur/client_spec.rb
|
177
|
+
- spec/monitaur_spec.rb
|
178
|
+
- spec/spec_helper.rb
|
179
|
+
- spec/support/bar_plugin.rb
|
180
|
+
- spec/support/client_requests.rb
|
181
|
+
- spec/support/foo_plugin.rb
|
182
|
+
- spec/support/test.rb
|
183
|
+
has_rdoc: true
|
184
|
+
homepage: http://github.com/danryan/overwatch-client
|
185
|
+
licenses:
|
186
|
+
- MIT
|
187
|
+
post_install_message:
|
188
|
+
rdoc_options: []
|
189
|
+
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
hash: 1674726256609455612
|
198
|
+
segments:
|
199
|
+
- 0
|
200
|
+
version: "0"
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ">"
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: 1.3.1
|
207
|
+
requirements: []
|
208
|
+
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 1.6.2
|
211
|
+
signing_key:
|
212
|
+
specification_version: 3
|
213
|
+
summary: Client for Overwatch monitoring service
|
214
|
+
test_files: []
|
215
|
+
|