maatkit-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/Changelog +0 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +26 -0
  4. data/lib/maatkit-ruby.rb +11 -0
  5. data/lib/maatkit-ruby/mk-archiver.rb +473 -0
  6. data/lib/maatkit-ruby/mk-checksum-filter.rb +122 -0
  7. data/lib/maatkit-ruby/mk-deadlock-logger.rb +223 -0
  8. data/lib/maatkit-ruby/mk-duplicate-key-checker.rb +239 -0
  9. data/lib/maatkit-ruby/mk-error-log.rb +240 -0
  10. data/lib/maatkit-ruby/mk-fifo-split.rb +130 -0
  11. data/lib/maatkit-ruby/mk-find.rb +137 -0
  12. data/lib/maatkit-ruby/mk-heartbeat.rb +300 -0
  13. data/lib/maatkit-ruby/mk-index-usage.rb +164 -0
  14. data/lib/maatkit-ruby/mk-kill.rb +124 -0
  15. data/lib/maatkit-ruby/mk-loadavg.rb +313 -0
  16. data/lib/maatkit-ruby/mk-log-player.rb +316 -0
  17. data/lib/maatkit-ruby/mk-merge-mqd-results.rb +248 -0
  18. data/lib/maatkit-ruby/mk-parallel-dump.rb +400 -0
  19. data/lib/maatkit-ruby/mk-parallel-restore.rb +133 -0
  20. data/lib/maatkit-ruby/mk-profile-compact.rb +87 -0
  21. data/lib/maatkit-ruby/mk-purge-logs.rb +99 -0
  22. data/lib/maatkit-ruby/mk-query-advisor.rb +105 -0
  23. data/lib/maatkit-ruby/mk-query-digest.rb +149 -0
  24. data/lib/maatkit-ruby/mk-query-profiler.rb +106 -0
  25. data/lib/maatkit-ruby/mk-show-grants.rb +103 -0
  26. data/lib/maatkit-ruby/mk-slave-delay.rb +102 -0
  27. data/lib/maatkit-ruby/mk-slave-find.rb +98 -0
  28. data/lib/maatkit-ruby/mk-slave-move.rb +99 -0
  29. data/lib/maatkit-ruby/mk-slave-prefetch.rb +124 -0
  30. data/lib/maatkit-ruby/mk-slave-restart.rb +116 -0
  31. data/lib/maatkit-ruby/mk-table-checksum.rb +151 -0
  32. data/lib/maatkit-ruby/mk-table-sync.rb +468 -0
  33. data/lib/maatkit-ruby/mk-upgrade.rb +118 -0
  34. data/lib/maatkit-ruby/mk-variable-advisor.rb +99 -0
  35. data/lib/maatkit-ruby/mk-visual-explain.rb +98 -0
  36. data/lib/maatkit-ruby/version.rb +17 -0
  37. data/setup.rb +1585 -0
  38. data/test/test_helper.rb +2 -0
  39. data/test/test_maatkit_ruby.rb +11 -0
  40. metadata +105 -0
@@ -0,0 +1,106 @@
1
+ # = maatkit-ruby - A maatkit gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/maatkit-ruby
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # Execute SQL statements and print statistics, or measure activity caused by other processes.
10
+ #
11
+ # Maatkit::QueryProfiler.new( array, str, array)
12
+ #
13
+ class Maatkit::QueryProfiler
14
+
15
+ attr_accessor :allow_cache # FALSE
16
+ attr_accessor :ask_pass # FALSE
17
+ attr_accessor :calibrate # TRUE
18
+ attr_accessor :charset # (No # value)
19
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_query_profiler.conf,/home/joel/.maatkit.conf,/home/joel/.mk_query_profiler.conf
20
+ attr_accessor :database # (No # value)
21
+ attr_accessor :defaults_file # (No # value)
22
+ attr_accessor :external # FALSE
23
+ attr_accessor :flush # 0
24
+ attr_accessor :help # TRUE
25
+ attr_accessor :host # (No # value)
26
+ attr_accessor :innodb # TRUE
27
+ attr_accessor :only # (No # value)
28
+ attr_accessor :password # (No # value)
29
+ attr_accessor :pid # (No # value)
30
+ attr_accessor :port # (No # value)
31
+ attr_accessor :separate # FALSE
32
+ attr_accessor :session # TRUE
33
+ attr_accessor :set_vars # wait_timeout=10000
34
+ attr_accessor :socket # (No # value)
35
+ attr_accessor :tab # FALSE
36
+ attr_accessor :user # (No # value)
37
+ attr_accessor :verbose # 0
38
+ attr_accessor :verify # FALSE
39
+ attr_accessor :version # FALSE
40
+
41
+ #
42
+ # Sets the executable path, otherwise the environment path will be used.
43
+ #
44
+ attr_accessor :path_to_mk_query_profiler
45
+
46
+ #
47
+ # Returns a new QueryProfiler Object
48
+ #
49
+ def initialize()
50
+ end
51
+
52
+ #
53
+ # Execute the command
54
+ #
55
+ def start(options = nil)
56
+ tmp = Tempfile.new('tmp')
57
+ command = option_string() + options.to_s + " 2> " + tmp.path
58
+ success = system(command)
59
+ if success
60
+ begin
61
+ while (line = tmp.readline)
62
+ line.chomp
63
+ selected_string = line
64
+ end
65
+ rescue EOFError
66
+ tmp.close
67
+ end
68
+ return selected_string
69
+ else
70
+ tmp.close!
71
+ return success
72
+ end
73
+ end
74
+
75
+ def config
76
+ option_string()
77
+ end
78
+
79
+ private
80
+
81
+ def option_string()
82
+
83
+ unless @path_to_mk_query_profiler
84
+ ostring = "mk-query-profiler "
85
+ else
86
+ ostring = @path_to_mk_query_profiler + " "
87
+ end
88
+
89
+ self.instance_variables.each do |i|
90
+ tmp_value = self.instance_variable_get "#{i}"
91
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
92
+ unless tmp_string == "--path-to-mk-query-profiler"
93
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
94
+ ostring += "#{tmp_string} "
95
+ else
96
+ ostring += "#{tmp_string} #{tmp_value} "
97
+ end
98
+ end
99
+ end
100
+
101
+ return ostring
102
+
103
+ end
104
+
105
+ end
106
+
@@ -0,0 +1,103 @@
1
+ # = maatkit-ruby - A maatkit gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/maatkit-ruby
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # Canonicalize and print MySQL grants so you can effectively replicate, compare and version-control them.
10
+ #
11
+ # Maatkit::ShowGrants.new( array, str, array)
12
+ #
13
+ class Maatkit::ShowGrants
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :charset # (No # value)
17
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_show_grants.conf,/home/joel/.maatkit.conf,/home/joel/.mk_show_grants.conf
18
+ attr_accessor :database # (No # value)
19
+ attr_accessor :defaults_file # (No # value)
20
+ attr_accessor :drop # FALSE
21
+ attr_accessor :flush # FALSE
22
+ attr_accessor :header # TRUE
23
+ attr_accessor :help # TRUE
24
+ attr_accessor :host # (No # value)
25
+ attr_accessor :ignore # (No # value)
26
+ attr_accessor :only # (No # value)
27
+ attr_accessor :password # (No # value)
28
+ attr_accessor :pid # (No # value)
29
+ attr_accessor :port # (No # value)
30
+ attr_accessor :revoke # FALSE
31
+ attr_accessor :separate # FALSE
32
+ attr_accessor :set_vars # wait_timeout=10000
33
+ attr_accessor :socket # (No # value)
34
+ attr_accessor :timestamp # TRUE
35
+ attr_accessor :user # (No # value)
36
+ attr_accessor :version # FALSE
37
+
38
+ #
39
+ # Sets the executable path, otherwise the environment path will be used.
40
+ #
41
+ attr_accessor :path_to_mk_show_grants
42
+
43
+ #
44
+ # Returns a new ShowGrants Object
45
+ #
46
+ def initialize()
47
+ end
48
+
49
+ #
50
+ # Execute the command
51
+ #
52
+ def start(options = nil)
53
+ tmp = Tempfile.new('tmp')
54
+ command = option_string() + options.to_s + " 2> " + tmp.path
55
+ success = system(command)
56
+ if success
57
+ begin
58
+ while (line = tmp.readline)
59
+ line.chomp
60
+ selected_string = line
61
+ end
62
+ rescue EOFError
63
+ tmp.close
64
+ end
65
+ return selected_string
66
+ else
67
+ tmp.close!
68
+ return success
69
+ end
70
+ end
71
+
72
+ def config
73
+ option_string()
74
+ end
75
+
76
+ private
77
+
78
+ def option_string()
79
+
80
+ unless @path_to_mk_show_grants
81
+ ostring = "mk-show-grants "
82
+ else
83
+ ostring = @path_to_mk_show_grants + " "
84
+ end
85
+
86
+ self.instance_variables.each do |i|
87
+ tmp_value = self.instance_variable_get "#{i}"
88
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
89
+ unless tmp_string == "--path-to-mk-show-grants"
90
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
91
+ ostring += "#{tmp_string} "
92
+ else
93
+ ostring += "#{tmp_string} #{tmp_value} "
94
+ end
95
+ end
96
+ end
97
+
98
+ return ostring
99
+
100
+ end
101
+
102
+ end
103
+
@@ -0,0 +1,102 @@
1
+ # = maatkit-ruby - A maatkit gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/maatkit-ruby
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # Make a MySQL slave server lag behind its master.
10
+ #
11
+ # Maatkit::SlaveDelay.new( array, str, array)
12
+ #
13
+ class Maatkit::SlaveDelay
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :charset # (No # value)
17
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_slave_delay.conf,/home/joel/.maatkit.conf,/home/joel/.mk_slave_delay.conf
18
+ attr_accessor :continue # TRUE
19
+ attr_accessor :daemonize # FALSE
20
+ attr_accessor :defaults_file # (No # value)
21
+ attr_accessor :delay # 3600
22
+ attr_accessor :help # TRUE
23
+ attr_accessor :host # (No # value)
24
+ attr_accessor :interval # 60
25
+ attr_accessor :log # (No # value)
26
+ attr_accessor :password # (No # value)
27
+ attr_accessor :pid # (No # value)
28
+ attr_accessor :port # (No # value)
29
+ attr_accessor :quiet # FALSE
30
+ attr_accessor :run_time # (No # value)
31
+ attr_accessor :set_vars # wait_timeout=10000
32
+ attr_accessor :socket # (No # value)
33
+ attr_accessor :use_master # FALSE
34
+ attr_accessor :user # (No # value)
35
+ attr_accessor :version # FALSE
36
+
37
+ #
38
+ # Sets the executable path, otherwise the environment path will be used.
39
+ #
40
+ attr_accessor :path_to_mk_slave_delay
41
+
42
+ #
43
+ # Returns a new SlaveDelay Object
44
+ #
45
+ def initialize()
46
+ end
47
+
48
+ #
49
+ # Execute the command
50
+ #
51
+ def start(options = nil)
52
+ tmp = Tempfile.new('tmp')
53
+ command = option_string() + options.to_s + " 2> " + tmp.path
54
+ success = system(command)
55
+ if success
56
+ begin
57
+ while (line = tmp.readline)
58
+ line.chomp
59
+ selected_string = line
60
+ end
61
+ rescue EOFError
62
+ tmp.close
63
+ end
64
+ return selected_string
65
+ else
66
+ tmp.close!
67
+ return success
68
+ end
69
+ end
70
+
71
+ def config
72
+ option_string()
73
+ end
74
+
75
+ private
76
+
77
+ def option_string()
78
+
79
+ unless @path_to_mk_slave_delay
80
+ ostring = "mk-slave-delay "
81
+ else
82
+ ostring = @path_to_mk_slave_delay + " "
83
+ end
84
+
85
+ self.instance_variables.each do |i|
86
+ tmp_value = self.instance_variable_get "#{i}"
87
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
88
+ unless tmp_string == "--path-to-mk-slave-delay"
89
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
90
+ ostring += "#{tmp_string} "
91
+ else
92
+ ostring += "#{tmp_string} #{tmp_value} "
93
+ end
94
+ end
95
+ end
96
+
97
+ return ostring
98
+
99
+ end
100
+
101
+ end
102
+
@@ -0,0 +1,98 @@
1
+ # = maatkit-ruby - A maatkit gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/maatkit-ruby
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # Find and print replication hierarchy tree of MySQL slaves.
10
+ #
11
+ # Maatkit::SlaveFind.new( array, str, array)
12
+ #
13
+ class Maatkit::SlaveFind
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :charset # (No # value)
17
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_slave_find.conf,/home/joel/.maatkit.conf,/home/joel/.mk_slave_find.conf
18
+ attr_accessor :database # FALSE
19
+ attr_accessor :defaults_file # (No # value)
20
+ attr_accessor :help # TRUE
21
+ attr_accessor :host # (No # value)
22
+ attr_accessor :password # (No # value)
23
+ attr_accessor :pid # (No # value)
24
+ attr_accessor :port # (No # value)
25
+ attr_accessor :recurse # FALSE
26
+ attr_accessor :recursion_method # (No # value)
27
+ attr_accessor :report_format # summary
28
+ attr_accessor :set_vars # wait_timeout=10000
29
+ attr_accessor :socket # (No # value)
30
+ attr_accessor :user # (No # value)
31
+ attr_accessor :version # FALSE
32
+
33
+ #
34
+ # Sets the executable path, otherwise the environment path will be used.
35
+ #
36
+ attr_accessor :path_to_mk_slave_find
37
+
38
+ #
39
+ # Returns a new SlaveFind Object
40
+ #
41
+ def initialize()
42
+ end
43
+
44
+ #
45
+ # Execute the command
46
+ #
47
+ def start(options = nil)
48
+ tmp = Tempfile.new('tmp')
49
+ command = option_string() + options.to_s + " 2> " + tmp.path
50
+ success = system(command)
51
+ if success
52
+ begin
53
+ while (line = tmp.readline)
54
+ line.chomp
55
+ selected_string = line
56
+ end
57
+ rescue EOFError
58
+ tmp.close
59
+ end
60
+ return selected_string
61
+ else
62
+ tmp.close!
63
+ return success
64
+ end
65
+ end
66
+
67
+ def config
68
+ option_string()
69
+ end
70
+
71
+ private
72
+
73
+ def option_string()
74
+
75
+ unless @path_to_mk_slave_find
76
+ ostring = "mk-slave-find "
77
+ else
78
+ ostring = @path_to_mk_slave_find + " "
79
+ end
80
+
81
+ self.instance_variables.each do |i|
82
+ tmp_value = self.instance_variable_get "#{i}"
83
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
84
+ unless tmp_string == "--path-to-mk-slave-find"
85
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
86
+ ostring += "#{tmp_string} "
87
+ else
88
+ ostring += "#{tmp_string} #{tmp_value} "
89
+ end
90
+ end
91
+ end
92
+
93
+ return ostring
94
+
95
+ end
96
+
97
+ end
98
+
@@ -0,0 +1,99 @@
1
+ # = maatkit-ruby - A maatkit gem for Ruby
2
+ #
3
+ # Homepage:: http://github.com/jjuliano/maatkit-ruby
4
+ # Author:: Joel Bryan Juliano
5
+ # Copyright:: (cc) 2011 Joel Bryan Juliano
6
+ # License:: MIT
7
+
8
+ #
9
+ # Move a MySQL slave around in the replication hierarchy.
10
+ #
11
+ # Maatkit::SlaveMove.new( array, str, array)
12
+ #
13
+ class Maatkit::SlaveMove
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :charset # (No # value)
17
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_slave_move.conf,/home/joel/.maatkit.conf,/home/joel/.mk_slave_move.conf
18
+ attr_accessor :defaults_file # (No # value)
19
+ attr_accessor :detach # FALSE
20
+ attr_accessor :help # TRUE
21
+ attr_accessor :host # (No # value)
22
+ attr_accessor :password # (No # value)
23
+ attr_accessor :pid # (No # value)
24
+ attr_accessor :port # (No # value)
25
+ attr_accessor :set_vars # wait_timeout=10000
26
+ attr_accessor :sibling_of_master # FALSE
27
+ attr_accessor :slave_of_sibling # FALSE
28
+ attr_accessor :slave_of_uncle # FALSE
29
+ attr_accessor :socket # (No # value)
30
+ attr_accessor :timeout # 600
31
+ attr_accessor :user # (No # value)
32
+ attr_accessor :version # FALSE
33
+
34
+ #
35
+ # Sets the executable path, otherwise the environment path will be used.
36
+ #
37
+ attr_accessor :path_to_mk_slave_move
38
+
39
+ #
40
+ # Returns a new SlaveMove Object
41
+ #
42
+ def initialize()
43
+ end
44
+
45
+ #
46
+ # Execute the command
47
+ #
48
+ def start(options = nil)
49
+ tmp = Tempfile.new('tmp')
50
+ command = option_string() + options.to_s + " 2> " + tmp.path
51
+ success = system(command)
52
+ if success
53
+ begin
54
+ while (line = tmp.readline)
55
+ line.chomp
56
+ selected_string = line
57
+ end
58
+ rescue EOFError
59
+ tmp.close
60
+ end
61
+ return selected_string
62
+ else
63
+ tmp.close!
64
+ return success
65
+ end
66
+ end
67
+
68
+ def config
69
+ option_string()
70
+ end
71
+
72
+ private
73
+
74
+ def option_string()
75
+
76
+ unless @path_to_mk_slave_move
77
+ ostring = "mk-slave-move "
78
+ else
79
+ ostring = @path_to_mk_slave_move + " "
80
+ end
81
+
82
+ self.instance_variables.each do |i|
83
+ tmp_value = self.instance_variable_get "#{i}"
84
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
85
+ unless tmp_string == "--path-to-mk-slave-move"
86
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
87
+ ostring += "#{tmp_string} "
88
+ else
89
+ ostring += "#{tmp_string} #{tmp_value} "
90
+ end
91
+ end
92
+ end
93
+
94
+ return ostring
95
+
96
+ end
97
+
98
+ end
99
+