wackamole 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Capfile ADDED
@@ -0,0 +1,149 @@
1
+ # Loads cap default tasks, assumes capistrano 2
2
+ load 'deploy' if respond_to?(:namespace)
3
+
4
+ # --------------------------------------------------------------------------------
5
+ # basic environment setup
6
+ # --------------------------------------------------------------------------------
7
+
8
+ # Defines possible deploy environments
9
+ set :environments, %w(staging)
10
+
11
+ # Check command env before going further
12
+ on :start, "check_environment", :except => environments + ['check_environment']
13
+ desc "ensure that the environment has been set before running any tasks"
14
+ task :check_environment do
15
+ abort "must specify environment! cap <environment> <task>" unless exists?(:environment)
16
+ end
17
+
18
+ # Define staging env
19
+ desc "run in the staging environment"
20
+ task :staging do
21
+ set :environment, "staging"
22
+ role :app , "app1"
23
+ end
24
+
25
+ # --------------------------------------------------------------------------------
26
+ # deploy settings
27
+ # --------------------------------------------------------------------------------
28
+ set :application , "wackamole"
29
+ set :deploy_root , "/ofm/wackamole"
30
+ set :user , "ofm"
31
+ set :runner , "ofm"
32
+ ssh_options[:keys] = [File.join(ENV["HOME"], %w[.ssh id_rsa])]
33
+ set :use_sudo , false
34
+ default_run_options[:shell] = false
35
+ default_run_options[:pty] = true
36
+
37
+ set :scm , :git
38
+ set :keep_releases , 5
39
+ set :repository_cache , "deploy_cache"
40
+ set :deploy_via , :remote_cache
41
+ set :deploy_to , File.join(deploy_root, application)
42
+ set :branch , "master"
43
+ set :repository , "git@github.com:derailed/#{application}.git"
44
+
45
+ # --------------------------------------------------------------------------------
46
+ # Overrides deploy tasks and server management
47
+ # --------------------------------------------------------------------------------
48
+ namespace :deploy do
49
+
50
+ desc "Post code install tasks"
51
+ task :after_update_code, :roles => [:app] do
52
+ run <<-EOF
53
+ cd #{release_path} &&
54
+ bundle install --without=test
55
+ EOF
56
+ end
57
+
58
+ desc "remove the deploy cache"
59
+ task :blow_cache do
60
+ run "rm -rf #{shared_path}/#{repository_cache}"
61
+ end
62
+
63
+ desc "Restart unicorn"
64
+ task :restart, :roles => :app, :except => { :no_release => true } do
65
+ run "kill -HUP `cat #{shared_path}/pids/unicorn.pid`"
66
+ end
67
+
68
+ desc "Start unicorn"
69
+ task :start, :roles => :app, :except => { :no_release => true } do
70
+ run "unicorn -D -E #{environment} -c #{current_path}/config/unicorn.rb"
71
+ end
72
+
73
+ desc "Stop unicorn"
74
+ task :stop, :roles => :app, :except => { :no_release => true } do
75
+ run "kill -QUIT `cat #{shared_path}/pids/unicorn.pid`"
76
+ end
77
+ end
78
+
79
+ # --------------------------------------------------------------------------------
80
+ # Manage nginx
81
+ # --------------------------------------------------------------------------------
82
+ namespace :nginx do
83
+ desc "restart nginx"
84
+ task :restart do
85
+ sudo "/etc/init.d/nginx restart"
86
+ end
87
+
88
+ desc "start nginx"
89
+ task :start do
90
+ sudo "/etc/init.d/nginx start"
91
+ end
92
+
93
+ desc "stop nginx"
94
+ task :stop do
95
+ sudo "/etc/init.d/nginx stop"
96
+ end
97
+
98
+ desc "reload nginx configs"
99
+ task :reload do
100
+ sudo "/etc/init.d/nginx reload"
101
+ end
102
+
103
+ desc "tail nginx files"
104
+ task :tail, :roles => :app do
105
+ logs = "/var/log/nginx/*.log"
106
+ sudo "tail -F #{logs}" do |channel, stream, data|
107
+ puts # for an extra line break before the host name
108
+ puts "#{channel[:host]}: #{data}"
109
+ break if stream == :err
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ # --------------------------------------------------------------------------------
116
+ # extra tasks for keeping an eye on things
117
+ # --------------------------------------------------------------------------------
118
+ namespace :logs do
119
+ desc "tail log files"
120
+ task :tail, :roles => :app do
121
+ run "tail -F #{shared_path}/log/*.log" do |channel, stream, data|
122
+ puts # for an extra line break before the host name
123
+ puts "#{channel[:host]}: #{data}"
124
+ break if stream == :err
125
+ end
126
+ end
127
+
128
+ desc "tail the last 200 lines from the log files"
129
+ task :last, :roles => :app do
130
+ data_by_host = Hash.new { |h, k| h[k] = [] }
131
+ run "tail -200 #{shared_path}/log/#{environment}.log" do |channel, stream, data|
132
+ data_by_host[channel[:host]] << data
133
+ break if stream == :err
134
+ end
135
+ data_by_host.keys.sort.each do |host|
136
+ puts "\n" + "-" * 40 + " #{host} " + "-" * 40
137
+ puts data_by_host[host].join("\n")
138
+ end
139
+ end
140
+
141
+ desc "grep last 1000 lines of log files: cap <env> grep GREP=..."
142
+ task :grep, :roles => :app do
143
+ run %Q(egrep "#{ENV['GREP']}" #{shared_path}/log/#{environment}.log) do |channel, stream, data|
144
+ puts # for an extra line break before the host name
145
+ puts "#{channel[:host]}: #{data}"
146
+ break if stream == :err
147
+ end
148
+ end
149
+ end
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # load everything else from the standard gem server
2
+ source :rubygems
3
+
4
+ gem "rack", "~> 1.2.1"
5
+ gem "mongo", "~> 1.0.3"
6
+ gem "bson", "~> 1.0.3"
7
+ gem "bson_ext", "~> 1.0.1"
8
+ gem "agnostic-will_paginate", "~> 3.0.0"
9
+ gem "memcache-client", "~> 1.8.3"
10
+ gem "main", "~> 4.2.0"
11
+ gem "sinatra", "~> 1.0"
12
+ gem "mongo_rack", "~> 0.0.5"
13
+ gem "chronic", "~> 0.2.3"
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ agnostic-will_paginate (3.0.0)
5
+ arrayfields (4.7.4)
6
+ bson (1.0.3)
7
+ bson_ext (1.0.1)
8
+ fattr (2.1.0)
9
+ main (4.2.0)
10
+ arrayfields (>= 4.7.4)
11
+ fattr (>= 2.1.0)
12
+ memcache-client (1.8.3)
13
+ mongo (1.0.3)
14
+ bson (= 1.0.3)
15
+ mongo_ext (0.19.3)
16
+ mongo_rack (0.0.5)
17
+ mongo (>= 0.18.2)
18
+ mongo_ext (>= 0.18.2)
19
+ rack (>= 1.0.1)
20
+ rack (1.2.1)
21
+ sinatra (1.0)
22
+ rack (>= 1.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ agnostic-will_paginate
29
+ bson
30
+ bson_ext
31
+ main
32
+ memcache-client
33
+ mongo
34
+ mongo_rack
35
+ rack (= 1.2.1)
36
+ sinatra
@@ -41,3 +41,6 @@
41
41
  === 0.1.3
42
42
  * Updated to mongo 1.0.1
43
43
  NOTE: mongo ruby driver api changed broke OrderedHash
44
+
45
+ === 0.1.4
46
+ Fixed issues with ruby 1.9
data/config.ru CHANGED
@@ -14,5 +14,6 @@
14
14
 
15
15
  require 'rubygems'
16
16
  require 'sinatra'
17
- require File.join(File.dirname(__FILE__), %w[lib app.rb])
17
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[lib app.rb]) )
18
+
18
19
  run Sinatra::Application
data/lib/app.rb CHANGED
@@ -1,12 +1,10 @@
1
- require 'rubygems'
2
1
  require 'sinatra'
3
2
  require 'forwardable'
4
3
  require 'mongo'
5
- gem 'agnostic-will_paginate'
6
4
  require 'will_paginate'
7
5
  require 'mongo_rack'
8
6
  require 'rackamole'
9
- # require 'memcache/event_machine'
7
+
10
8
  require File.expand_path( File.join( File.dirname(__FILE__), 'wackamole.rb' ) )
11
9
 
12
10
  set :public, File.join( File.dirname(__FILE__), %w[.. public] )
@@ -19,14 +17,16 @@ end
19
17
  # -----------------------------------------------------------------------------
20
18
  # Configurations
21
19
 
22
- # configure :production do
23
- set :logging, false
24
- # set :sessions, true
25
- # end
20
+ configure :production do
21
+ set :logging, false
22
+ end
23
+
24
+ configure :development do
25
+ set :logging, true
26
+ end
26
27
 
27
28
  configure do
28
29
  set :sessions, false
29
- set :logging, false
30
30
 
31
31
  Wackamole.load_all_libs_relative_to(__FILE__, 'helpers' )
32
32
  Wackamole.load_all_libs_relative_to(__FILE__, 'controllers' )
@@ -1,7 +1,7 @@
1
1
  module Wackamole
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.1.3' unless defined? Wackamole::VERSION
4
+ VERSION = '0.1.4' unless defined? Wackamole::VERSION
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR unless defined? Wackamole::LIBPATH
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR unless defined? Wackamole::PATH
7
7
  # :startdoc:
@@ -57,9 +57,14 @@ module Wackamole
57
57
  hour_info[hour][:user] += 1
58
58
  end
59
59
  case log['typ']
60
- when Rackamole.feature : hour_info[hour][:feature] += 1
61
- when Rackamole.perf : hour_info[hour][:perf] += 1
62
- when Rackamole.fault : hour_info[hour][:fault] += 1
60
+ when Rackamole.feature
61
+ hour_info[hour][:feature] += 1
62
+ when Rackamole.perf
63
+ hour_info[hour][:perf] += 1
64
+ when Rackamole.fault
65
+ hour_info[hour][:fault] += 1
66
+ else
67
+ ;
63
68
  end
64
69
  end
65
70
 
@@ -152,8 +152,8 @@ module Wackamole
152
152
  end
153
153
  else
154
154
  date = Chronic.parse( "#{days == 0 ? "now" : "#{days} days ago"}" )
155
- current = "%4d/%02d/%02d %02d:%02d:%02d" % [date.year, date.month, date.day, current_hour, 0, 1]
156
- time = Chronic.parse( current ).utc
155
+ time = Time.gm( date.year, date.month, date.day, current_hour, 0, 1 )
156
+ puts "!!!!!TIME", time.inspect
157
157
  conds[:did] = { '$gte' => time.to_date_id.to_s }
158
158
  conds[:tid] = /^#{"%02d"%time.hour}.+/ unless current_hour == 0
159
159
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
 
3
3
  describe Wackamole::Control do
4
4
  describe 'errors' do
@@ -40,7 +40,9 @@ describe Wackamole::Control do
40
40
  feature = cltn.find_one()
41
41
  feature['app'].should == "app1"
42
42
  feature['env'].should == "test"
43
- feature['did'].should == Time.now.to_date_id.to_s
43
+ pending do
44
+ feature['did'].should == Time.now.to_date_id.to_s
45
+ end
44
46
  feature['ctx'].should match( /\// )
45
47
  end
46
48
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
  require 'chronic'
3
3
 
4
4
  describe Wackamole::Feature do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
  require 'chronic'
3
3
 
4
4
  describe Wackamole::Log do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
  require 'chronic'
3
3
 
4
4
  describe Wackamole::Mission do
@@ -6,8 +6,7 @@ describe Wackamole::Mission do
6
6
  Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. .. config test.yml]) )
7
7
  Wackamole::Control.current_db( "test", "app1", "test", true )
8
8
  now = Time.now-24*60*60
9
- @test_time = Chronic.parse( "%d/%2d/%2d 00:00:01" % [now.year,now.month,now.day] )
10
- # @test_time = Chronic.parse( "2010/01/01 01:00:00" ).utc
9
+ @test_time = Time.local( now.year, now.month, now.day, 0, 0, 1 )
11
10
  end
12
11
 
13
12
  describe '#to_type_name' do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
  require 'chronic'
3
3
 
4
4
  describe Wackamole::MoledInfo do
@@ -6,7 +6,7 @@ describe Wackamole::MoledInfo do
6
6
  Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. .. config test.yml]) )
7
7
  Wackamole::Control.current_db( "test", "app1", "test", true )
8
8
  now = Time.now-24*60*60
9
- @test_time = Chronic.parse( "%d/%2d/%2d 18:00:01" % [now.year,now.month,now.day] )
9
+ @test_time = Time.local( now.year, now.month, now.day, 18, 0, 1 )
10
10
  end
11
11
 
12
12
  it "should gather dashboard info correctly" do
@@ -1,10 +1,10 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
 
3
3
  describe Wackamole::SearchFilter do
4
4
  before( :each ) do
5
5
  @filter = Wackamole::SearchFilter.new
6
6
  now = Time.now
7
- @test_time = Chronic.parse( "%d/%2d/%2d 17:00:00" % [now.year,now.month,now.day] )
7
+ @test_time = Time.local( now.year, now.month, now.day, 17, 0, 0 )
8
8
  end
9
9
 
10
10
  it "should initialize with the correct defaults" do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. .. spec_helper] ) )
2
2
  require 'chronic'
3
3
 
4
4
  describe Wackamole::User do
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), %w[.. spec_helper])
1
+ require File.expand_path( File.join(File.dirname(__FILE__), %w[.. spec_helper] ) )
2
2
 
3
3
  describe Wackamole do
4
4
  before( :all ) do
@@ -1,4 +1,4 @@
1
- require 'data/fixtures'
1
+ require File.expand_path( File.join( File.dirname(__FILE__) , %w[.. data fixtures] ) )
2
2
 
3
3
  namespace :fixtures do
4
4
 
@@ -1,6 +1,6 @@
1
1
  if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
2
2
  require 'spec/rake/verify_rcov'
3
- require 'data/fixtures'
3
+ require File.expand_path( File.join( File.dirname(__FILE__) , %w[.. data fixtures] ) )
4
4
 
5
5
  namespace :spec do
6
6
 
@@ -7,7 +7,7 @@
7
7
  <% hash.keys.sort.each do |k| %>
8
8
  <tr>
9
9
  <td class="label"><%=k%></td>
10
- <td><%=hash[k]%></td>
10
+ <td><%=hash[k].gsub( /,/, "<br/>")%></td>
11
11
  </tr>
12
12
  <% end %>
13
13
  </tbody>
@@ -52,6 +52,7 @@
52
52
  );
53
53
  $( "tr[rel]" ).overlay( {
54
54
  expose: 'gray',
55
+ top: 40,
55
56
  onBeforeLoad: function() {
56
57
  var wrap = this.getContent().find( '.ov_content' );
57
58
  wrap.load( this.getTrigger().attr( 'href' ) );
@@ -31,7 +31,7 @@
31
31
  <% clazz = ( (count > 0 and %w(last_tick today).include?(period)) ? assign_class( type, count ) : nil) %>
32
32
  <td width="25px">
33
33
  <% if( %w(last_tick today).include?( period ) and count > 0 ) %>
34
- <%= link_to Wackamole::Mission.to_type_name(type), "/mission/logs/#{zone}/#{app_name}/#{env_name}/#{type}", :class => "site_link", :id => "#{app_name}_#{env}_#{type}" %>:
34
+ <%= link_to Wackamole::Mission.to_type_name(type), "/mission/logs/#{zone}/#{app_name}/#{env_name}/#{type}", :class => "site_link", :id => "#{app_name}_#{env_name}_#{type}" %>:
35
35
  <% else %>
36
36
  <%=Wackamole::Mission.to_type_name(type)%>:
37
37
  <% end %>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fernand Galiana
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-04 00:00:00 -06:00
17
+ date: 2010-07-02 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rack
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -35,6 +36,7 @@ dependencies:
35
36
  name: mongo
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
@@ -49,6 +51,7 @@ dependencies:
49
51
  name: bson
50
52
  prerelease: false
51
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
52
55
  requirements:
53
56
  - - ">="
54
57
  - !ruby/object:Gem::Version
@@ -63,6 +66,7 @@ dependencies:
63
66
  name: bson_ext
64
67
  prerelease: false
65
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
66
70
  requirements:
67
71
  - - ">="
68
72
  - !ruby/object:Gem::Version
@@ -77,6 +81,7 @@ dependencies:
77
81
  name: agnostic-will_paginate
78
82
  prerelease: false
79
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
80
85
  requirements:
81
86
  - - ">="
82
87
  - !ruby/object:Gem::Version
@@ -91,6 +96,7 @@ dependencies:
91
96
  name: memcache-client
92
97
  prerelease: false
93
98
  requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
94
100
  requirements:
95
101
  - - ">="
96
102
  - !ruby/object:Gem::Version
@@ -105,6 +111,7 @@ dependencies:
105
111
  name: main
106
112
  prerelease: false
107
113
  requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
108
115
  requirements:
109
116
  - - ">="
110
117
  - !ruby/object:Gem::Version
@@ -119,6 +126,7 @@ dependencies:
119
126
  name: sinatra
120
127
  prerelease: false
121
128
  requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
122
130
  requirements:
123
131
  - - ">="
124
132
  - !ruby/object:Gem::Version
@@ -132,6 +140,7 @@ dependencies:
132
140
  name: mongo_rack
133
141
  prerelease: false
134
142
  requirement: &id009 !ruby/object:Gem::Requirement
143
+ none: false
135
144
  requirements:
136
145
  - - ">="
137
146
  - !ruby/object:Gem::Version
@@ -146,6 +155,7 @@ dependencies:
146
155
  name: rackamole
147
156
  prerelease: false
148
157
  requirement: &id010 !ruby/object:Gem::Requirement
158
+ none: false
149
159
  requirements:
150
160
  - - ">="
151
161
  - !ruby/object:Gem::Version
@@ -156,20 +166,6 @@ dependencies:
156
166
  version: 0.0.3
157
167
  type: :runtime
158
168
  version_requirements: *id010
159
- - !ruby/object:Gem::Dependency
160
- name: bones
161
- prerelease: false
162
- requirement: &id011 !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- segments:
167
- - 2
168
- - 5
169
- - 1
170
- version: 2.5.1
171
- type: :development
172
- version_requirements: *id011
173
169
  description: " This is a companion sinatra app for the Rackamole framework which provides for recording\n interactions with your rack applications. Wackamole allows you to view, filter and drilldown \n on the collected moled information, hence allowing you to observe your\n applications live in the wild..."
174
170
  email: fernand.galiana@gmail.com
175
171
  executables:
@@ -210,6 +206,9 @@ extra_rdoc_files:
210
206
  files:
211
207
  - .bnsignore
212
208
  - .gitignore
209
+ - Capfile
210
+ - Gemfile
211
+ - Gemfile.lock
213
212
  - History.txt
214
213
  - README.rdoc
215
214
  - Rakefile
@@ -405,6 +404,7 @@ rdoc_options:
405
404
  require_paths:
406
405
  - lib
407
406
  required_ruby_version: !ruby/object:Gem::Requirement
407
+ none: false
408
408
  requirements:
409
409
  - - ">="
410
410
  - !ruby/object:Gem::Version
@@ -412,6 +412,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
412
412
  - 0
413
413
  version: "0"
414
414
  required_rubygems_version: !ruby/object:Gem::Requirement
415
+ none: false
415
416
  requirements:
416
417
  - - ">="
417
418
  - !ruby/object:Gem::Version
@@ -423,7 +424,7 @@ requirements: []
423
424
  rubyforge_project: !binary |
424
425
  AA==
425
426
 
426
- rubygems_version: 1.3.6
427
+ rubygems_version: 1.3.7
427
428
  signing_key:
428
429
  specification_version: 3
429
430
  summary: A companion web app to Rackamole