poolboy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/README.md +7 -0
- data/bin/poolboy +3 -1
- data/lib/poolboy/{55.rb → five_five.rb} +0 -0
- data/lib/poolboy/{51.rb → five_one.rb} +0 -0
- data/lib/poolboy/mysql.rb +14 -9
- data/lib/poolboy/screen.rb +7 -7
- data/lib/poolboy/version.rb +1 -1
- data/lib/poolboy.rb +55 -43
- metadata +15 -7
- checksums.yaml +0 -15
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/bin/poolboy
CHANGED
File without changes
|
File without changes
|
data/lib/poolboy/mysql.rb
CHANGED
@@ -1,32 +1,37 @@
|
|
1
1
|
require 'mysql2'
|
2
2
|
|
3
|
-
class
|
3
|
+
class MysqlConnection
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(options)
|
6
6
|
begin
|
7
|
-
@mysql = Mysql2::Client.new(:
|
7
|
+
@mysql = Mysql2::Client.new(options.merge({:database => 'information_schema', :connect_timeout => 2, :symbolize_keys => true}))
|
8
8
|
rescue Mysql2::Error => e
|
9
9
|
puts e
|
10
|
-
exit
|
10
|
+
exit 1
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def version
|
15
|
-
version =
|
15
|
+
version = query("SHOW VARIABLES LIKE 'version'")
|
16
16
|
return version.first[:Value]
|
17
17
|
end
|
18
18
|
|
19
|
+
def percona
|
20
|
+
xtra = query("show variables like 'innodb_import_table_from_xtrabackup'")
|
21
|
+
return xtra.count >= 1 ? true : false
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
19
25
|
def query(query)
|
20
26
|
begin
|
21
|
-
|
22
|
-
return results
|
27
|
+
@mysql.query(query)
|
23
28
|
rescue Mysql2::Error => e
|
24
29
|
puts e
|
25
|
-
exit
|
30
|
+
exit 1
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
29
|
-
def disconnect
|
34
|
+
def disconnect
|
30
35
|
@mysql.close
|
31
36
|
end
|
32
37
|
end
|
data/lib/poolboy/screen.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
require 'curses'
|
2
1
|
|
3
2
|
class Screen
|
4
3
|
|
5
|
-
def
|
4
|
+
def initialize(window)
|
5
|
+
@win = window
|
6
|
+
@width = @win.maxx
|
7
|
+
@hight = @win.maxy
|
8
|
+
end
|
9
|
+
|
10
|
+
def show_message(message)
|
6
11
|
@win.setpos(0, 0)
|
7
12
|
message['stats'].each do |s|
|
8
13
|
pool_size = (s.fetch(:pages_misc).to_i + s.fetch(:pages_data).to_i * s.fetch(:page_size).to_i / 1024 / 1024)
|
@@ -34,9 +39,4 @@ require 'curses'
|
|
34
39
|
@win.refresh
|
35
40
|
end
|
36
41
|
|
37
|
-
def self.open_screen()
|
38
|
-
@win = Curses::Window.new(0,0,0,0)
|
39
|
-
@width = @win.maxx
|
40
|
-
@hight = @win.maxy
|
41
|
-
end
|
42
42
|
end
|
data/lib/poolboy/version.rb
CHANGED
data/lib/poolboy.rb
CHANGED
@@ -1,62 +1,74 @@
|
|
1
1
|
require 'poolboy/screen'
|
2
2
|
require 'poolboy/mysql'
|
3
|
-
require 'poolboy/
|
4
|
-
require 'poolboy/
|
3
|
+
require 'poolboy/five_five'
|
4
|
+
require 'poolboy/five_one'
|
5
5
|
require 'optparse'
|
6
6
|
require 'yaml'
|
7
|
+
require 'curses'
|
7
8
|
|
8
9
|
module Poolboy
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def Poolboy.execute
|
12
|
+
|
13
|
+
options = YAML.load(File.read(ENV['HOME']+'/.poolboy.yaml')) rescue {}
|
14
|
+
|
15
|
+
o = OptionParser.new do |opts|
|
16
|
+
opts.on("-h HOST") do |h|
|
17
|
+
options[:host] = h
|
18
|
+
end
|
19
|
+
opts.on("-u USER") do |u|
|
20
|
+
options[:username] = u
|
21
|
+
end
|
22
|
+
opts.on("-p PASSWORD") do |p|
|
23
|
+
options[:password] = p
|
24
|
+
end
|
25
|
+
opts.on("-r REFRESH", Integer) do |r|
|
26
|
+
options[:refresh] = r >= 1 ? r : 1
|
27
|
+
end
|
28
|
+
if not options.has_key?(:refresh)
|
29
|
+
options[:refresh] = 5
|
30
|
+
end
|
14
31
|
end
|
15
|
-
|
16
|
-
|
32
|
+
|
33
|
+
begin o.parse!
|
34
|
+
rescue OptionParser::InvalidOption => e
|
35
|
+
puts e
|
36
|
+
puts o
|
37
|
+
exit 128
|
17
38
|
end
|
18
|
-
|
19
|
-
|
39
|
+
|
40
|
+
connection = MysqlConnection.new(options)
|
41
|
+
connection.percona
|
42
|
+
percona = connection.percona ? connection.percona : version_exit
|
43
|
+
version = connection.version
|
44
|
+
|
45
|
+
case version[0,3]
|
46
|
+
when '5.1'
|
47
|
+
mysql_map = FiveOne
|
48
|
+
when '5.5'
|
49
|
+
mysql_map = FiveFive
|
50
|
+
else
|
51
|
+
version_exit
|
20
52
|
end
|
21
|
-
end.parse!
|
22
53
|
|
23
|
-
|
54
|
+
window = Curses::Window.new(0,0,0,0)
|
55
|
+
screen = Screen.new(window)
|
56
|
+
|
24
57
|
begin
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
if not options.has_key?(:user)
|
30
|
-
options[:user] = config_file["user"]
|
58
|
+
while true
|
59
|
+
results = mysql_map.get_stats(connection)
|
60
|
+
screen.show_message(results)
|
61
|
+
sleep(options[:refresh])
|
31
62
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rescue Errno::ENOENT
|
63
|
+
rescue SystemExit, Interrupt
|
64
|
+
connection.disconnect
|
65
|
+
exit
|
36
66
|
end
|
37
67
|
end
|
38
68
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
mysql_map = FiveOne
|
43
|
-
elsif version[0,3] == '5.5'
|
44
|
-
mysql_map = FiveFive
|
45
|
-
else
|
46
|
-
puts "Incompatible MySQL version. Poolboy is only compatable with Percona Server."
|
47
|
-
exit
|
48
|
-
end
|
49
|
-
screen = Screen
|
50
|
-
screen::open_screen()
|
51
|
-
|
52
|
-
begin
|
53
|
-
while true
|
54
|
-
results = mysql_map::get_stats(my_con)
|
55
|
-
screen::show_message(results)
|
56
|
-
sleep(1)
|
57
|
-
end
|
58
|
-
rescue SystemExit, Interrupt
|
59
|
-
exit
|
69
|
+
def Poolboy.version_exit
|
70
|
+
puts "Incompatible MySQL version! Poolboy is only compatible with Percona Server 5.1 and 5.5"
|
71
|
+
exit 1
|
60
72
|
end
|
61
73
|
|
62
74
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poolboy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Sam
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: mysql2
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: bundler
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -67,8 +74,8 @@ files:
|
|
67
74
|
- Rakefile
|
68
75
|
- bin/poolboy
|
69
76
|
- lib/poolboy.rb
|
70
|
-
- lib/poolboy/
|
71
|
-
- lib/poolboy/
|
77
|
+
- lib/poolboy/five_five.rb
|
78
|
+
- lib/poolboy/five_one.rb
|
72
79
|
- lib/poolboy/mysql.rb
|
73
80
|
- lib/poolboy/screen.rb
|
74
81
|
- lib/poolboy/version.rb
|
@@ -76,25 +83,26 @@ files:
|
|
76
83
|
homepage: http://www.samlambert.com
|
77
84
|
licenses:
|
78
85
|
- MIT
|
79
|
-
metadata: {}
|
80
86
|
post_install_message:
|
81
87
|
rdoc_options: []
|
82
88
|
require_paths:
|
83
89
|
- lib
|
84
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
85
92
|
requirements:
|
86
93
|
- - ! '>='
|
87
94
|
- !ruby/object:Gem::Version
|
88
95
|
version: '0'
|
89
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
90
98
|
requirements:
|
91
99
|
- - ! '>='
|
92
100
|
- !ruby/object:Gem::Version
|
93
101
|
version: '0'
|
94
102
|
requirements: []
|
95
103
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
104
|
+
rubygems_version: 1.8.24
|
97
105
|
signing_key:
|
98
|
-
specification_version:
|
106
|
+
specification_version: 3
|
99
107
|
summary: Poolboy lets you view the data in your buffer pool
|
100
108
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZjIwZTBhYWMyNGNjODJiNzg0YzlkYTAxNzdkMTFlNGI4ZTg2YWMzZA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NDJhYTcyNTE3NzFlNzUyYjAxOTA2ZmIwZGQ4Yzc1MzRjYzEwZjQ4YQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NjQwMWJmNjJmNjUwMTk1ODkzMWQ0NGJkMTdmNGIwZjQ2MzNlMmE3NDAxY2U5
|
10
|
-
MGMxNmMzNGQ0OWE4MDUyYTkzYTFhZGI4MWU2Y2VjNzQ1N2E3MTcxM2U4OGY5
|
11
|
-
ODcyNTNhODFiZWE2MjU2YmU1ODQ2ZDAyMWY1NzcwNzE2M2M2MzM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODE4MmFhYjEwOWI0MWJjZTBlOTYzODRhMmViNzcxMDk3NGUwZjY2MGRkODlj
|
14
|
-
YTRmMGY0MWY4NTA0ZTc5ODRkYWNkMGE3NThhYTY0MmFiM2UxMWNiNDVmM2E3
|
15
|
-
NTY3ZDRiZDI2ZDk0ZDA1NzdhNzYzYzRmNDYwYmUzYjk0OWQzMGQ=
|