poolboy 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -17,7 +17,7 @@ spec/reports
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
-
20
+ poolboy/
21
21
  # YARD artifacts
22
22
  .yardoc
23
23
  _yardoc
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Poolboy
2
2
 
3
3
 
4
- host: 127.0.0.1
5
- user: root
6
- pass: pass
7
- refresh: 5
4
+ :host: 127.0.0.1
5
+ :username: root
6
+ :password: kraken123
7
+ :refresh: 5
8
+ :force: false
8
9
 
9
10
 
10
11
  TODO: Write a gem description
data/lib/poolboy/mysql.rb CHANGED
@@ -17,8 +17,8 @@ class MysqlConnection
17
17
  end
18
18
 
19
19
  def percona
20
- xtra = query("show variables like 'innodb_import_table_from_xtrabackup'")
21
- return xtra.count >= 1 ? true : false
20
+ xtra = query("show variables like 'version_comment'")
21
+ return (xtra.first[:Value].include? "Percona") ? true : false
22
22
  exit
23
23
  end
24
24
 
@@ -1,3 +1,3 @@
1
1
  module Poolboy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/poolboy.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'poolboy/screen'
2
+ require 'poolboy/version'
2
3
  require 'poolboy/mysql'
3
4
  require 'poolboy/five_five'
4
5
  require 'poolboy/five_one'
@@ -9,39 +10,50 @@ require 'curses'
9
10
  module Poolboy
10
11
 
11
12
  def Poolboy.execute
12
-
13
13
  options = YAML.load(File.read(ENV['HOME']+'/.poolboy.yaml')) rescue {}
14
14
 
15
15
  o = OptionParser.new do |opts|
16
- opts.on("-h HOST") do |h|
16
+ opts.banner = "Poolboy helps you inspect your buffer pool\n\nUsage: poolboy [options]"
17
+ opts.on("-h HOST", "MySQL hostname") do |h|
17
18
  options[:host] = h
18
19
  end
19
- opts.on("-u USER") do |u|
20
+ opts.on("-u USER", "MySQL username") do |u|
20
21
  options[:username] = u
21
22
  end
22
- opts.on("-p PASSWORD") do |p|
23
+ opts.on("-p PASSWORD", "MySQL password") do |p|
23
24
  options[:password] = p
24
25
  end
25
- opts.on("-r REFRESH", Integer) do |r|
26
+ opts.on("-r REFRESH", Integer, "Refresh interval") do |r|
26
27
  options[:refresh] = r >= 1 ? r : 1
27
28
  end
28
- if not options.has_key?(:refresh)
29
- options[:refresh] = 5
29
+ options[:refresh] = options.has_key?(:refresh) ? options[:refresh] : 5
30
+ opts.on("-f", "Force skipping of Percona Server check") do |r|
31
+ options[:force] = true
32
+ end
33
+ options[:force] = options.has_key?(:force) ? options[:force] : false
34
+ opts.on_tail("--help", "Show this message") do
35
+ puts opts
36
+ exit
37
+ end
38
+ opts.on_tail("--version", "Show version") do
39
+ puts VERSION
40
+ exit
30
41
  end
31
42
  end
32
43
 
33
44
  begin o.parse!
34
- rescue OptionParser::InvalidOption => e
45
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
35
46
  puts e
36
47
  puts o
37
48
  exit 128
38
49
  end
39
50
 
40
51
  connection = MysqlConnection.new(options)
41
- connection.percona
42
- percona = connection.percona ? connection.percona : version_exit
52
+ if not options[:force]
53
+ connection.percona
54
+ percona = connection.percona ? connection.percona : version_exit
55
+ end
43
56
  version = connection.version
44
-
45
57
  case version[0,3]
46
58
  when '5.1'
47
59
  mysql_map = FiveOne
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poolboy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: