overwatch 0.0.3.pre → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/.watchr CHANGED
@@ -16,7 +16,3 @@ end
16
16
  watch("lib/(.*/.*)\.rb") do |match|
17
17
  run_spec %{spec/#{match[1]}_spec.rb}
18
18
  end
19
-
20
- watch("lib/monitaur.rb") do |match|
21
- run_spec %{spec/monitaur_spec.rb}
22
- end
data/Gemfile CHANGED
@@ -1,18 +1,14 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
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'
3
+ gemspec
7
4
 
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'
5
+ group :development, :test do
6
+ gem 'rspec', '>= 2.6.0'
7
+ gem 'spork', '>= 0.9.0.rc8'
8
+ gem 'watchr', '>= 0.7'
9
+ gem 'json_spec', '>= 0.5.0'
10
+ end
11
+
12
+ group :doc do
13
+ gem 'yard'
18
14
  end
data/README.md CHANGED
@@ -1,29 +1,171 @@
1
- # overwatch-client
1
+ # Installation
2
2
 
3
- Client for the Overwatch monitoring service
3
+ gem install overwatch-cli
4
4
 
5
- ## Installation
5
+
6
+ # Usage
6
7
 
7
- The client is installed via rubygems
8
+ I'm going to assume you've got overwatch-collection running somewhere on your local machine for the purpose of this documention.
8
9
 
9
- gem install overwatch
10
+ ## Help!
11
+
12
+ All commands provide a contextual help menu. Apped `--selp` to the end of any command or subcommand to bring up its specific help menu.
13
+
14
+ ## Main command
15
+
16
+ When you install `overwatch-cli` via RubyGems, an executable, `overwatch`, is installed somewhere in your $PATH (the exact location is entirely dependent upon your Ruby/Gems setup).
17
+
18
+ #### Usage:
19
+ overwatch [OPTIONS] SUBCOMMAND [ARGS] ...
20
+
21
+ #### Parameters
22
+
23
+ SUBCOMMAND subcommand name
24
+ [ARGS] ... subcommand arguments
25
+
26
+ #### Subcommands
27
+
28
+ run Compile and send a new snapshot to the server
29
+ resource Resources
30
+ snapshot Snapshots
31
+
32
+
33
+ ## Subcommands
34
+
35
+ ### overwatch run
36
+
37
+ #### Usage
38
+
39
+ overwatch run [OPTIONS] [ARGS] ...
40
+
41
+ #### Parameters
42
+
43
+ SUBCOMMAND subcommand name
44
+ [ARGS] ... subcommand arguments
45
+
46
+ #### Options
47
+
48
+ -k, --key KEY API key (default: nil)
49
+ -s, --server SERVER collection server (default: "localhost")
50
+ -p, --port PORT collection port (default: "9001")
51
+ -f, --format [FORMAT] format (choices: pretty, json, text) (default: "pretty")
52
+
53
+
54
+ ### overwatch resource
55
+
56
+ #### Usage
57
+
58
+ overwatch resource [OPTIONS] SUBCOMMAND [ARGS] ...
59
+
60
+ #### Parameters
61
+
62
+ SUBCOMMAND subcommand name
63
+ [ARGS] ... subcommand arguments
64
+
65
+ #### Subcommands
66
+
67
+ list list all resources
68
+ show show a specific resource
69
+ create create a new resource
70
+ update update an existing resource
71
+ delete delete an existing resource
72
+ regenerate regenerate a resource's API key
73
+
74
+ #### Options
75
+
76
+ -s, --server SERVER overwatch-collection server (default: "localhost")
77
+ -p, --port PORT overwatch-collection port (default: "9001")
78
+ -f, --format [FORMAT] format (choices: pretty, json, text) (default: "pretty")
79
+
80
+ ### overwatch resource list
81
+
82
+ #### Usage
83
+
84
+ overwatch resource list [OPTIONS]
85
+
86
+ #### Options
87
+
88
+ -s, --server SERVER overwatch-collection server (default: "localhost")
89
+ -p, --port PORT overwatch-collection port (default: "9001")
90
+ -f, --format [FORMAT] format (choices: pretty, json, text) (default: "pretty")
91
+
92
+ #### Examples:
93
+
94
+ Pretty format:
95
+
96
+ $ overwatch resource list --format pretty
97
+ +----+------+--------------------------------+
98
+ | id | name | api_key |
99
+ +----+------+--------------------------------+
100
+ | 1 | foo | 3ec97eb0d2870db4b061533812d8a1 |
101
+ | 2 | bar | e0a5f1baf553f27115cb45ea1ef51a |
102
+ | 3 | baz | 5273d592d9a7465ed1b3ae820d06a1 |
103
+ +----+------+--------------------------------+
104
+ 3 rows in set
105
+
106
+ Plaintext format for easy piping/grepping/awking:
107
+
108
+ $ overwatch resource list --format text
109
+ 1 foo 3ec97eb0d2870db4b061533812d8a1
110
+ 2 bar e0a5f1baf553f27115cb45ea1ef51a
111
+ 3 baz 5273d592d9a7465ed1b3ae820d06a1
112
+
113
+
114
+ ### overwatch resource show
115
+
116
+ #### Usage
10
117
 
11
- This creates the executable `overwatch`. Currently there is no daemon, so you can run it as a cron job:
118
+ overwatch resource show [OPTIONS] NAME_OR_ID
119
+
120
+ #### Parameters
12
121
 
13
- * * * * * overwatch <api key>
122
+ NAME_OR_ID resource name or id
123
+
124
+ #### Options
125
+
126
+ -a, --attributes list all resource attributes
127
+ -s, --server SERVER overwatch-collection server (default: "localhost")
128
+ -p, --port PORT overwatch-collection port (default: "9001")
129
+ -f, --format [FORMAT] format (choices: pretty, json, text) (default: "pretty")
130
+
131
+ #### Example
132
+
133
+ Find a resource by _name_ and display it
134
+
135
+ $ overwatch resource show foo
136
+ +----+------+--------------------------------+
137
+ | id | name | api_key |
138
+ +----+------+--------------------------------+
139
+ | 1 | foo | 3ec97eb0d2870db4b061533812d8a1 |
140
+ +----+------+--------------------------------+
141
+ 1 row in set
142
+
143
+ Find a resource by _id_ and display it in plain text:
144
+
145
+ $ overwatch resource show --format text 2
146
+ 2 bar e0a5f1baf553f27115cb45ea1ef51a
147
+
148
+ ### overwatch resource delete
149
+
150
+ raise NotImplementedError, "This will be available in a future release."
151
+
152
+ ### overwatch resource update
153
+
154
+ raise NotImplementedError, "This will be available in a future release."
14
155
 
15
- ## Plugins
156
+ ### overwatch resource regenerate
157
+
158
+ raise NotImplementedError, "This will be available in a future release."
159
+
160
+ ### overwatch snapshot
16
161
 
17
- Plugins are stored client-side for ease of deployment by your configuration management service. See the Plugin wiki for more info.
162
+ raise NotImplementedError, "This will be available in a future release."
18
163
 
19
- ## Client run
20
164
 
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
165
 
25
- ## Copyright
166
+ ## TODO
26
167
 
27
- Copyright (c) 2011 Dan Ryan. See LICENSE.txt for
28
- further details.
168
+ * dotfile for configuration of defaults
169
+ * expand command set as other overwatch pieces are implemented
170
+ * user authentication/authorization (done in the other apps, but we'll need support here)
29
171
 
data/Rakefile CHANGED
@@ -1,50 +1,42 @@
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
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
10
4
  require 'rake'
11
5
 
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
6
+ # require 'resque/tasks'
7
+ # require 'resque_scheduler/tasks'
8
+
9
+ require 'bundler/gem_tasks'
30
10
 
31
- require 'rspec/core'
32
11
  require 'rspec/core/rake_task'
33
- RSpec::Core::RakeTask.new(:spec) do |spec|
34
- spec.pattern = FileList['spec/**/*_spec.rb']
12
+
13
+ desc "Run specs"
14
+ RSpec::Core::RakeTask.new do |task|
15
+ task.pattern = "spec/**/*_spec.rb"
16
+ end
17
+
18
+ desc "Run watchr"
19
+ task :watchr do
20
+ sh %{bundle exec watchr .watchr}
35
21
  end
36
22
 
37
- RSpec::Core::RakeTask.new(:rcov) do |spec|
38
- spec.pattern = 'spec/**/*_spec.rb'
39
- spec.rcov = true
23
+ desc "Run spork"
24
+ task :spork do
25
+ sh %{bundle exec spork}
40
26
  end
41
27
 
42
- task :default => :spec
43
28
 
44
- require 'yard'
45
- YARD::Rake::YardocTask.new
29
+ Bundler.require(:doc)
30
+ desc "Generate documentation"
31
+ YARD::Rake::YardocTask.new do |t|
32
+ t.files = [ 'lib/**/*.rb' ]
33
+ end
46
34
 
47
- desc "Run watchr"
48
- task :watchr do
49
- sh %{bundle exec watchr .watchr}
35
+ namespace :overwatch do
36
+ namespace :test do
37
+ task :snapshot => :environment do
38
+ a = Resource.first
39
+ a.snapshots.create(:data => {:one => rand(10), :two => { :three => rand(10) }})
40
+ end
41
+ end
50
42
  end
@@ -1,18 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
 
4
- require 'rubygems'
5
-
6
- $LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. lib])
3
+ $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
7
4
 
8
5
  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]
6
+ require 'clamp'
13
7
 
14
- begin
15
- Overwatch.run api_key
16
- rescue => e
17
- puts e
18
- end
8
+ Overwatch::Command.run
@@ -0,0 +1,6 @@
1
+ collection:
2
+ host: localhost
3
+ events:
4
+ host: localhost
5
+ checks:
6
+ host: localhost
@@ -1,106 +1,12 @@
1
- require 'logger'
2
- require 'fileutils'
3
- require 'rest-client'
4
- require 'yajl'
5
-
6
- require 'overwatch/client'
7
-
8
1
  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
-
2
+ class << self
62
3
  def plugin_path
63
4
  @plugin_path ||= File.expand_path(File.join(File.dirname(__FILE__), "../plugins"))
64
5
  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
6
  end
106
7
  end
8
+
9
+ require 'overwatch/command'
10
+ require 'overwatch/helpers'
11
+ require 'overwatch/version'
12
+