passenger_dyno 0.0.1
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/LICENSE +20 -0
- data/README.mdown +22 -0
- data/Rakefile +61 -0
- data/VERSION +1 -0
- data/examples/config.yml +2 -0
- data/examples/database.yml +6 -0
- data/lib/dyno/dyno_server.rb +5 -0
- data/lib/dyno/dyno_server_check.rb +7 -0
- data/lib/dyno_check.rb +86 -0
- data/lib/mongo_store.rb +5 -0
- data/lib/passenger/passenger_overview.rb +9 -0
- data/lib/passenger/passenger_thread.rb +10 -0
- data/lib/passenger_dyno.rb +6 -0
- data/passenger_dyno.gemspec +78 -0
- data/pkg/passenger_dyno-0.0.1.gem +0 -0
- data/test/helper.rb +10 -0
- data/test/test_passenger_dyno.rb +7 -0
- data/utilities/dyno_daemon.rb +19 -0
- data/utilities/dyno_test.rb +11 -0
- metadata +149 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Bob Burbach
|
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.mdown
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= passenger_dyno
|
2
|
+
|
3
|
+
|
4
|
+
== Configuration
|
5
|
+
|
6
|
+
* place the dyno.yml file in /opt/dyno
|
7
|
+
* create the directory for the pid file (should already exist on most unix systems)
|
8
|
+
- mkdir -p /var/run
|
9
|
+
|
10
|
+
== Note on Patches/Pull Requests
|
11
|
+
|
12
|
+
* Fork the project.
|
13
|
+
* Make your feature addition or bug fix.
|
14
|
+
* Add tests for it. This is important so I don't break it in a
|
15
|
+
future version unintentionally.
|
16
|
+
* Commit, do not mess with rakefile, version, or history.
|
17
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
18
|
+
* Send me a pull request. Bonus points for topic branches.
|
19
|
+
|
20
|
+
== Copyright
|
21
|
+
|
22
|
+
Copyright (c) 2010 Bob Burbach. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "passenger_dyno"
|
8
|
+
gem.summary = "Make tracking passenger server usage easier with MongoDb"
|
9
|
+
gem.description = <<-EOF
|
10
|
+
Store passenger memory usage and other useful statitics in MongoDb. Use
|
11
|
+
passenger_dyno_clinet to see those stats rendered with javascript!
|
12
|
+
EOF
|
13
|
+
gem.email = "bob.burbach@gmail.com"
|
14
|
+
gem.homepage = "http://github.com/peregrinator/passenger_dyno"
|
15
|
+
gem.authors = ["Bob Burbach"]
|
16
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
17
|
+
gem.requirements << 'MongoDb >= 1.4.0'
|
18
|
+
gem.add_dependency('mongo', '>= 0.19.3')
|
19
|
+
gem.add_dependency('bson_ext', '>= 0.19.3')
|
20
|
+
gem.add_dependency('mongo_mapper', '>= 0.7.2')
|
21
|
+
gem.add_dependency('ghazel-daemons', '>= 1.0.12')
|
22
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
|
+
end
|
24
|
+
Jeweler::GemcutterTasks.new
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
require 'rcov/rcovtask'
|
38
|
+
Rcov::RcovTask.new do |test|
|
39
|
+
test.libs << 'test'
|
40
|
+
test.pattern = 'test/**/test_*.rb'
|
41
|
+
test.verbose = true
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
task :rcov do
|
45
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :test => :check_dependencies
|
50
|
+
|
51
|
+
task :default => :test
|
52
|
+
|
53
|
+
require 'rake/rdoctask'
|
54
|
+
Rake::RDocTask.new do |rdoc|
|
55
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
56
|
+
|
57
|
+
rdoc.rdoc_dir = 'rdoc'
|
58
|
+
rdoc.title = "passenger_dyno #{version}"
|
59
|
+
rdoc.rdoc_files.include('README*')
|
60
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
61
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/examples/config.yml
ADDED
data/lib/dyno_check.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'mongo'
|
3
|
+
require 'mongo_mapper'
|
4
|
+
|
5
|
+
class DynoCheck
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
config_path = options.delete(:config_path) || '/opt/dyno'
|
9
|
+
dyno_config = YAML::load(ERB.new(IO.read(File.join(config_path, 'config.yml'))).result)['dyno']
|
10
|
+
database_config = YAML::load(ERB.new(IO.read(File.join(config_path, 'database.yml'))).result)['mongo']
|
11
|
+
|
12
|
+
MongoMapper.connection = Mongo::Connection.new(database_config['host'], database_config['port'])
|
13
|
+
MongoMapper.database = database_config['database']
|
14
|
+
|
15
|
+
@servers = dyno_config['servers']
|
16
|
+
@passenger_memory_stats_output = `passenger-memory-stats`
|
17
|
+
@passenger_status_output = `passenger-status`
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
@servers.each do |server_name|
|
22
|
+
dyno_server = DynoServer.find_by_name(server_name)
|
23
|
+
if dyno_server.nil?
|
24
|
+
dyno_server = DynoServer.new(:name => server_name)
|
25
|
+
end
|
26
|
+
|
27
|
+
@current_time = Time.now
|
28
|
+
@dyno_server_check = DynoServerCheck.create(:checked_at => @current_time)
|
29
|
+
|
30
|
+
overview_check
|
31
|
+
thread_check
|
32
|
+
|
33
|
+
dyno_server.dyno_server_checks << @dyno_server_check
|
34
|
+
dyno_server.save
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def overview_check
|
39
|
+
# prints 6 lines
|
40
|
+
# Line 1 Total Apache worker processes
|
41
|
+
# Line 2 Total memory used by Apache worker processes
|
42
|
+
# Line 3 Total Nginx worker processes
|
43
|
+
# Line 4 Total memory used by Nginx worker processes
|
44
|
+
# Line 5 Total Passenger rails processes
|
45
|
+
# Line 6 Total memory used by Passenger rails processes
|
46
|
+
overview_stats = `grep '###' "#{@passenger_memory_stats_output}" | awk '{print $3"\t"$6}'`.split("\n")
|
47
|
+
|
48
|
+
apache_workers = overview_stats[0].split("\t")[0]
|
49
|
+
apache_memory = overview_stats[1].split("\t")[1]
|
50
|
+
passenger_process = overview_stats[4].split("\t")[0]
|
51
|
+
passenger_memory = overview_stats[5].split("\t")[1]
|
52
|
+
|
53
|
+
@dyno_server_check.overview = PassengerOverview.new(:total_apache_processes => apache_workers,
|
54
|
+
:total_apache_memory => apache_memory,
|
55
|
+
:total_passenger_processes => passenger_process,
|
56
|
+
:total_passenger_memory => passenger_memory)
|
57
|
+
end
|
58
|
+
|
59
|
+
def thread_check
|
60
|
+
# prints PID PrivateMem ProcessName
|
61
|
+
memory_threads = `grep 'MB.*Rails' "#{@passenger_memory_stats_output}" | awk '{ print $1"\t"$4"\t"$7 }'`.split('\n')
|
62
|
+
|
63
|
+
# prints PID Sessions Processed Uptime(min) Uptime(sec) seperated by tabs
|
64
|
+
status_threads = `grep 'PID: ' "#{@passenger_status_output}" | awk '{ print $2"\t"$4"\t"6"\t"$8"\t"$9 }'`.split('\n')
|
65
|
+
|
66
|
+
memory_threads.length.times do |i|
|
67
|
+
memory_thread = memory_threads[i-1].split("\t")
|
68
|
+
pid = memory_thread[0]
|
69
|
+
private_mem = memory_thread[1]
|
70
|
+
process_name = memory_thread[2]
|
71
|
+
|
72
|
+
status_thread = status_threads[i-1].split("\t")
|
73
|
+
sessions_waiting = status_thread[1]
|
74
|
+
sessions_processed = status_thread[2]
|
75
|
+
uptime = (status_thread[3] * 60) + status_thread[4]
|
76
|
+
|
77
|
+
@dyno_server_check.passenger_threads << PassengerThread.new(:pid => pid,
|
78
|
+
:private_mem => private_mem,
|
79
|
+
:process_name => process_name,
|
80
|
+
:sessions_waiting => sessions_waiting,
|
81
|
+
:sessions_processed => sessions_processed,
|
82
|
+
:uptime => uptime)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
data/lib/mongo_store.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{passenger_dyno}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Bob Burbach"]
|
12
|
+
s.date = %q{2010-04-10}
|
13
|
+
s.description = %q{ Store passenger memory usage and other useful statitics in MongoDb. Use
|
14
|
+
passenger_dyno_clinet to see those stats rendered with javascript!
|
15
|
+
}
|
16
|
+
s.email = %q{bob.burbach@gmail.com}
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.mdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"LICENSE",
|
23
|
+
"README.mdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"examples/config.yml",
|
27
|
+
"examples/database.yml",
|
28
|
+
"lib/dyno/dyno_server.rb",
|
29
|
+
"lib/dyno/dyno_server_check.rb",
|
30
|
+
"lib/dyno_check.rb",
|
31
|
+
"lib/mongo_store.rb",
|
32
|
+
"lib/passenger/passenger_overview.rb",
|
33
|
+
"lib/passenger/passenger_thread.rb",
|
34
|
+
"lib/passenger_dyno.rb",
|
35
|
+
"passenger_dyno.gemspec",
|
36
|
+
"pkg/passenger_dyno-0.0.1.gem",
|
37
|
+
"test/helper.rb",
|
38
|
+
"test/test_passenger_dyno.rb",
|
39
|
+
"utilities/dyno_daemon.rb",
|
40
|
+
"utilities/dyno_test.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://github.com/peregrinator/passenger_dyno}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.requirements = ["MongoDb >= 1.4.0"]
|
46
|
+
s.rubygems_version = %q{1.3.6}
|
47
|
+
s.summary = %q{Make tracking passenger server usage easier with MongoDb}
|
48
|
+
s.test_files = [
|
49
|
+
"test/helper.rb",
|
50
|
+
"test/test_passenger_dyno.rb"
|
51
|
+
]
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<mongo>, [">= 0.19.3"])
|
60
|
+
s.add_runtime_dependency(%q<bson_ext>, [">= 0.19.3"])
|
61
|
+
s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.7.2"])
|
62
|
+
s.add_runtime_dependency(%q<ghazel-daemons>, [">= 1.0.12"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
65
|
+
s.add_dependency(%q<mongo>, [">= 0.19.3"])
|
66
|
+
s.add_dependency(%q<bson_ext>, [">= 0.19.3"])
|
67
|
+
s.add_dependency(%q<mongo_mapper>, [">= 0.7.2"])
|
68
|
+
s.add_dependency(%q<ghazel-daemons>, [">= 1.0.12"])
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
72
|
+
s.add_dependency(%q<mongo>, [">= 0.19.3"])
|
73
|
+
s.add_dependency(%q<bson_ext>, [">= 0.19.3"])
|
74
|
+
s.add_dependency(%q<mongo_mapper>, [">= 0.7.2"])
|
75
|
+
s.add_dependency(%q<ghazel-daemons>, [">= 1.0.12"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
Binary file
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'daemons'
|
4
|
+
require 'passenger_dyno'
|
5
|
+
|
6
|
+
|
7
|
+
daemon_options = {
|
8
|
+
:multiple => false,
|
9
|
+
:dir_mode => :normal,
|
10
|
+
:dir => '/var/run',
|
11
|
+
:backtrace => true
|
12
|
+
}
|
13
|
+
|
14
|
+
dyno = DynoCheck.new
|
15
|
+
|
16
|
+
Daemons.run_proc('passenger_dyno_runner', daemon_options) do
|
17
|
+
dyno.run
|
18
|
+
sleep(60)
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: passenger_dyno
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Bob Burbach
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-10 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: mongo
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
- 19
|
42
|
+
- 3
|
43
|
+
version: 0.19.3
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bson_ext
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
- 19
|
56
|
+
- 3
|
57
|
+
version: 0.19.3
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: mongo_mapper
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
- 7
|
70
|
+
- 2
|
71
|
+
version: 0.7.2
|
72
|
+
type: :runtime
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: ghazel-daemons
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 1
|
83
|
+
- 0
|
84
|
+
- 12
|
85
|
+
version: 1.0.12
|
86
|
+
type: :runtime
|
87
|
+
version_requirements: *id005
|
88
|
+
description: " Store passenger memory usage and other useful statitics in MongoDb. Use\n passenger_dyno_clinet to see those stats rendered with javascript!\n"
|
89
|
+
email: bob.burbach@gmail.com
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files:
|
95
|
+
- LICENSE
|
96
|
+
- README.mdown
|
97
|
+
files:
|
98
|
+
- LICENSE
|
99
|
+
- README.mdown
|
100
|
+
- Rakefile
|
101
|
+
- VERSION
|
102
|
+
- examples/config.yml
|
103
|
+
- examples/database.yml
|
104
|
+
- lib/dyno/dyno_server.rb
|
105
|
+
- lib/dyno/dyno_server_check.rb
|
106
|
+
- lib/dyno_check.rb
|
107
|
+
- lib/mongo_store.rb
|
108
|
+
- lib/passenger/passenger_overview.rb
|
109
|
+
- lib/passenger/passenger_thread.rb
|
110
|
+
- lib/passenger_dyno.rb
|
111
|
+
- passenger_dyno.gemspec
|
112
|
+
- pkg/passenger_dyno-0.0.1.gem
|
113
|
+
- test/helper.rb
|
114
|
+
- test/test_passenger_dyno.rb
|
115
|
+
- utilities/dyno_daemon.rb
|
116
|
+
- utilities/dyno_test.rb
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: http://github.com/peregrinator/passenger_dyno
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options:
|
123
|
+
- --charset=UTF-8
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
requirements:
|
141
|
+
- MongoDb >= 1.4.0
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 1.3.6
|
144
|
+
signing_key:
|
145
|
+
specification_version: 3
|
146
|
+
summary: Make tracking passenger server usage easier with MongoDb
|
147
|
+
test_files:
|
148
|
+
- test/helper.rb
|
149
|
+
- test/test_passenger_dyno.rb
|