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,133 @@
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
+ # Restore MySQL tables in parallel.
10
+ #
11
+ # Maatkit::ParallelRestore.new( array, str, array)
12
+ #
13
+ class Maatkit::ParallelRestore
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :atomic_resume # TRUE
17
+ attr_accessor :base_dir # /home/joel/maatkit_ruby/lib/maatkit_ruby
18
+ attr_accessor :biggest_first # TRUE
19
+ attr_accessor :bin_log # TRUE
20
+ attr_accessor :bulk_insert_buffer_size # (No # value)
21
+ attr_accessor :charset # BINARY
22
+ attr_accessor :commit # TRUE
23
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_parallel_restore.conf,/home/joel/.maatkit.conf,/home/joel/.mk_parallel_restore.conf
24
+ attr_accessor :create_databases # FALSE
25
+ attr_accessor :create_tables # TRUE
26
+ attr_accessor :csv # FALSE
27
+ attr_accessor :database # (No # value)
28
+ attr_accessor :databases # (No # value)
29
+ attr_accessor :databases_regex # (No # value)
30
+ attr_accessor :decompress # gzip # _d # _c
31
+ attr_accessor :defaults_file # (No # value)
32
+ attr_accessor :disable_keys # TRUE
33
+ attr_accessor :drop_tables # TRUE
34
+ attr_accessor :dry_run # FALSE
35
+ attr_accessor :fast_index # FALSE
36
+ attr_accessor :fifo # TRUE
37
+ attr_accessor :foreign_key_checks # TRUE
38
+ attr_accessor :help # TRUE
39
+ attr_accessor :host # (No # value)
40
+ attr_accessor :ignore # FALSE
41
+ attr_accessor :ignore_databases #
42
+ attr_accessor :ignore_tables #
43
+ attr_accessor :local # FALSE
44
+ attr_accessor :lock_tables # FALSE
45
+ attr_accessor :no_auto_value_on_0 # TRUE
46
+ attr_accessor :only_empty_databases # FALSE
47
+ attr_accessor :password # (No # value)
48
+ attr_accessor :pid # (No # value)
49
+ attr_accessor :port # (No # value)
50
+ attr_accessor :progress # FALSE
51
+ attr_accessor :quiet # FALSE
52
+ attr_accessor :replace # FALSE
53
+ attr_accessor :resume # TRUE
54
+ attr_accessor :set_vars # wait_timeout=10000
55
+ attr_accessor :socket # (No # value)
56
+ attr_accessor :tab # FALSE
57
+ attr_accessor :tables # (No # value)
58
+ attr_accessor :tables_regex # (No # value)
59
+ attr_accessor :threads # 2
60
+ attr_accessor :truncate # FALSE
61
+ attr_accessor :umask # 0
62
+ attr_accessor :unique_checks # TRUE
63
+ attr_accessor :user # (No # value)
64
+ attr_accessor :verbose # 1
65
+ attr_accessor :version # FALSE
66
+ attr_accessor :wait # 300
67
+
68
+ #
69
+ # Sets the executable path, otherwise the environment path will be used.
70
+ #
71
+ attr_accessor :path_to_mk_parallel_restore
72
+
73
+ #
74
+ # Returns a new ParallelRestore Object
75
+ #
76
+ def initialize()
77
+ end
78
+
79
+ #
80
+ # Execute the command
81
+ #
82
+ def start(options = nil)
83
+ tmp = Tempfile.new('tmp')
84
+ command = option_string() + options.to_s + " 2> " + tmp.path
85
+ success = system(command)
86
+ if success
87
+ begin
88
+ while (line = tmp.readline)
89
+ line.chomp
90
+ selected_string = line
91
+ end
92
+ rescue EOFError
93
+ tmp.close
94
+ end
95
+ return selected_string
96
+ else
97
+ tmp.close!
98
+ return success
99
+ end
100
+ end
101
+
102
+ def config
103
+ option_string()
104
+ end
105
+
106
+ private
107
+
108
+ def option_string()
109
+
110
+ unless @path_to_mk_parallel_restore
111
+ ostring = "mk-parallel-restore "
112
+ else
113
+ ostring = @path_to_mk_parallel_restore + " "
114
+ end
115
+
116
+ self.instance_variables.each do |i|
117
+ tmp_value = self.instance_variable_get "#{i}"
118
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
119
+ unless tmp_string == "--path-to-mk-parallel-restore"
120
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
121
+ ostring += "#{tmp_string} "
122
+ else
123
+ ostring += "#{tmp_string} #{tmp_value} "
124
+ end
125
+ end
126
+ end
127
+
128
+ return ostring
129
+
130
+ end
131
+
132
+ end
133
+
@@ -0,0 +1,87 @@
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
+ # Compact the output from mk-query-profiler.
10
+ #
11
+ # Maatkit::ProfileCompact.new( array, str, array)
12
+ #
13
+ class Maatkit::ProfileCompact
14
+
15
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk-profile-compact.conf,/home/joel/.maatkit.conf,/home/joel/.mk-profile-compact.conf
16
+ attr_accessor :headers # 2000
17
+ attr_accessor :help # TRUE
18
+ attr_accessor :mode # (No # value)
19
+ attr_accessor :queries # (No # value)
20
+ attr_accessor :version # FALSE
21
+
22
+ #
23
+ # Sets the executable path, otherwise the environment path will be used.
24
+ #
25
+ attr_accessor :path_to_mk_profile_compact
26
+
27
+ #
28
+ # Returns a new ProfileCompact Object
29
+ #
30
+ def initialize()
31
+ end
32
+
33
+ #
34
+ # Execute the command
35
+ #
36
+ def start(options = nil)
37
+ tmp = Tempfile.new('tmp')
38
+ command = option_string() + options.to_s + " 2> " + tmp.path
39
+ success = system(command)
40
+ if success
41
+ begin
42
+ while (line = tmp.readline)
43
+ line.chomp
44
+ selected_string = line
45
+ end
46
+ rescue EOFError
47
+ tmp.close
48
+ end
49
+ return selected_string
50
+ else
51
+ tmp.close!
52
+ return success
53
+ end
54
+ end
55
+
56
+ def config
57
+ option_string()
58
+ end
59
+
60
+ private
61
+
62
+ def option_string()
63
+
64
+ unless @path_to_mk_profile_compact
65
+ ostring = "mk-profile-compact "
66
+ else
67
+ ostring = @path_to_mk_profile_compact + " "
68
+ end
69
+
70
+ self.instance_variables.each do |i|
71
+ tmp_value = self.instance_variable_get "#{i}"
72
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
73
+ unless tmp_string == "--path-to-mk-profile-compact"
74
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
75
+ ostring += "#{tmp_string} "
76
+ else
77
+ ostring += "#{tmp_string} #{tmp_value} "
78
+ end
79
+ end
80
+ end
81
+
82
+ return ostring
83
+
84
+ end
85
+
86
+ end
87
+
@@ -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
+ # Purge binary logs on a master based on purge rules.
10
+ #
11
+ # Maatkit::PurgeLogs.new( array, str, array)
12
+ #
13
+ class Maatkit::PurgeLogs
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_purge_logs.conf,/home/joel/.maatkit.conf,/home/joel/.mk_purge_logs.conf
17
+ attr_accessor :defaults_file # (No # value)
18
+ attr_accessor :dry_run # FALSE
19
+ attr_accessor :help # TRUE
20
+ attr_accessor :password # (No # value)
21
+ attr_accessor :pid # (No # value)
22
+ attr_accessor :port # (No # value)
23
+ attr_accessor :print # FALSE
24
+ attr_accessor :purge # FALSE
25
+ attr_accessor :purge_rules # unused
26
+ attr_accessor :recursion_method # (No # value)
27
+ attr_accessor :set_vars # wait_timeout=10000
28
+ attr_accessor :socket # (No # value)
29
+ attr_accessor :total_size # (No # value)
30
+ attr_accessor :user # (No # value)
31
+ attr_accessor :verbose # FALSE
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_purge_logs
38
+
39
+ #
40
+ # Returns a new PurgeLogs 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_purge_logs
77
+ ostring = "mk-purge-logs "
78
+ else
79
+ ostring = @path_to_mk_purge_logs + " "
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-purge-logs"
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
+
@@ -0,0 +1,105 @@
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
+ # Analyze queries and advise on possible problems.
10
+ #
11
+ # Maatkit::QueryAdvisor.new( array, str, array)
12
+ #
13
+ class Maatkit::QueryAdvisor
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :charset # (No # value)
17
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_query_advisor.conf,/home/joel/.maatkit.conf,/home/joel/.mk_query_advisor.conf
18
+ attr_accessor :continue_on_error # TRUE
19
+ attr_accessor :daemonize # FALSE
20
+ attr_accessor :defaults_file # (No # value)
21
+ attr_accessor :help # TRUE
22
+ attr_accessor :host # (No # value)
23
+ attr_accessor :ignore_rules # (No # value)
24
+ attr_accessor :password # (No # value)
25
+ attr_accessor :pid # (No # value)
26
+ attr_accessor :port # (No # value)
27
+ attr_accessor :print_all # FALSE
28
+ attr_accessor :query # (No # value)
29
+ attr_accessor :report_format # compact
30
+ attr_accessor :review # (No # value)
31
+ attr_accessor :sample # 1
32
+ attr_accessor :set_vars # wait_timeout=10000
33
+ attr_accessor :socket # (No # value)
34
+ attr_accessor :type # slowlog
35
+ attr_accessor :user # (No # value)
36
+ attr_accessor :verbose # 1
37
+ attr_accessor :version # FALSE
38
+ attr_accessor :where # (No # value)
39
+
40
+ #
41
+ # Sets the executable path, otherwise the environment path will be used.
42
+ #
43
+ attr_accessor :path_to_mk_query_advisor
44
+
45
+ #
46
+ # Returns a new QueryAdvisor Object
47
+ #
48
+ def initialize()
49
+ end
50
+
51
+ #
52
+ # Execute the command
53
+ #
54
+ def start(options = nil)
55
+ tmp = Tempfile.new('tmp')
56
+ command = option_string() + options.to_s + " 2> " + tmp.path
57
+ success = system(command)
58
+ if success
59
+ begin
60
+ while (line = tmp.readline)
61
+ line.chomp
62
+ selected_string = line
63
+ end
64
+ rescue EOFError
65
+ tmp.close
66
+ end
67
+ return selected_string
68
+ else
69
+ tmp.close!
70
+ return success
71
+ end
72
+ end
73
+
74
+ def config
75
+ option_string()
76
+ end
77
+
78
+ private
79
+
80
+ def option_string()
81
+
82
+ unless @path_to_mk_query_advisor
83
+ ostring = "mk-query-advisor "
84
+ else
85
+ ostring = @path_to_mk_query_advisor + " "
86
+ end
87
+
88
+ self.instance_variables.each do |i|
89
+ tmp_value = self.instance_variable_get "#{i}"
90
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
91
+ unless tmp_string == "--path-to-mk-query-advisor"
92
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
93
+ ostring += "#{tmp_string} "
94
+ else
95
+ ostring += "#{tmp_string} #{tmp_value} "
96
+ end
97
+ end
98
+ end
99
+
100
+ return ostring
101
+
102
+ end
103
+
104
+ end
105
+
@@ -0,0 +1,149 @@
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
+ # Parses logs and more. Analyze, transform, filter, review and report on queries.
10
+ #
11
+ # Maatkit::QueryDigest.new( array, str, array)
12
+ #
13
+ class Maatkit::QueryDigest
14
+
15
+ attr_accessor :ask_pass # FALSE
16
+ attr_accessor :attribute_aliases # db|Schema
17
+ attr_accessor :attribute_value_limit # 4294967296
18
+ attr_accessor :aux_dsn # (No # value)
19
+ attr_accessor :charset # (No # value)
20
+ attr_accessor :check_attributes_limit # 1000
21
+ attr_accessor :config # /etc/maatkit/maatkit.conf,/etc/maatkit/mk_query_digest.conf,/home/joel/.maatkit.conf,/home/joel/.mk_query_digest.conf
22
+ attr_accessor :continue_on_error # TRUE
23
+ attr_accessor :create_review_history_table # FALSE
24
+ attr_accessor :create_review_table # FALSE
25
+ attr_accessor :daemonize # FALSE
26
+ attr_accessor :defaults_file # (No # value)
27
+ attr_accessor :embedded_attributes # (No # value)
28
+ attr_accessor :execute # (No # value)
29
+ attr_accessor :execute_throttle # (No # value)
30
+ attr_accessor :expected_range # 5,10
31
+ attr_accessor :explain # (No # value)
32
+ attr_accessor :filter # (No # value)
33
+ attr_accessor :fingerprints # FALSE
34
+ attr_accessor :for_explain # TRUE
35
+ attr_accessor :group_by # fingerprint
36
+ attr_accessor :gzip # TRUE
37
+ attr_accessor :help # TRUE
38
+ attr_accessor :host # (No # value)
39
+ attr_accessor :ignore_attributes # arg,cmd,insert_id,ip,port,Thread_id,timestamp,exptime,flags,key,res,val,server_id,offset,end_log_pos,Xid
40
+ attr_accessor :inherit_attributes # db,ts
41
+ attr_accessor :interval # .1
42
+ attr_accessor :iterations # 1
43
+ attr_accessor :limit # 95%:20
44
+ attr_accessor :log # (No # value)
45
+ attr_accessor :mirror # (No # value)
46
+ attr_accessor :order_by # Query_time:sum
47
+ attr_accessor :outliers # Query_time:1:10
48
+ attr_accessor :password # (No # value)
49
+ attr_accessor :pid # (No # value)
50
+ attr_accessor :pipeline_profile # FALSE
51
+ attr_accessor :port # (No # value)
52
+ attr_accessor :print # FALSE
53
+ attr_accessor :print_iterations # FALSE
54
+ attr_accessor :processlist # (No # value)
55
+ attr_accessor :progress # time,30
56
+ attr_accessor :read_timeout # (No # value)
57
+ attr_accessor :report # TRUE
58
+ attr_accessor :report_all # FALSE
59
+ attr_accessor :report_format # rusage,date,files,header,profile,query_report,prepared
60
+ attr_accessor :report_histogram # Query_time
61
+ attr_accessor :review # (No # value)
62
+ attr_accessor :review_history # (No # value)
63
+ attr_accessor :run_time # (No # value)
64
+ attr_accessor :sample # (No # value)
65
+ attr_accessor :save_results # (No # value)
66
+ attr_accessor :select #
67
+ attr_accessor :set_vars # wait_timeout=10000
68
+ attr_accessor :shorten # 1024
69
+ attr_accessor :show_all #
70
+ attr_accessor :since # (No # value)
71
+ attr_accessor :socket # (No # value)
72
+ attr_accessor :statistics # FALSE
73
+ attr_accessor :table_access # FALSE
74
+ attr_accessor :tcpdump_errors # (No # value)
75
+ attr_accessor :timeline # FALSE
76
+ attr_accessor :type # slowlog
77
+ attr_accessor :until # (No # value)
78
+ attr_accessor :user # (No # value)
79
+ attr_accessor :version # FALSE
80
+ attr_accessor :watch_server # (No # value)
81
+ attr_accessor :zero_admin # TRUE
82
+ attr_accessor :zero_bool # TRUE
83
+
84
+ #
85
+ # Sets the executable path, otherwise the environment path will be used.
86
+ #
87
+ attr_accessor :path_to_mk_query_digest
88
+
89
+ #
90
+ # Returns a new QueryDigest Object
91
+ #
92
+ def initialize()
93
+ end
94
+
95
+ #
96
+ # Execute the command
97
+ #
98
+ def start(options = nil)
99
+ tmp = Tempfile.new('tmp')
100
+ command = option_string() + options.to_s + " 2> " + tmp.path
101
+ success = system(command)
102
+ if success
103
+ begin
104
+ while (line = tmp.readline)
105
+ line.chomp
106
+ selected_string = line
107
+ end
108
+ rescue EOFError
109
+ tmp.close
110
+ end
111
+ return selected_string
112
+ else
113
+ tmp.close!
114
+ return success
115
+ end
116
+ end
117
+
118
+ def config
119
+ option_string()
120
+ end
121
+
122
+ private
123
+
124
+ def option_string()
125
+
126
+ unless @path_to_mk_query_digest
127
+ ostring = "mk-query-digest "
128
+ else
129
+ ostring = @path_to_mk_query_digest + " "
130
+ end
131
+
132
+ self.instance_variables.each do |i|
133
+ tmp_value = self.instance_variable_get "#{i}"
134
+ tmp_string = i.gsub("_", "-").gsub("@", "--")
135
+ unless tmp_string == "--path-to-mk-query-digest"
136
+ if (tmp_value.is_a? TrueClass) || (tmp_value.is_a? FalseClass)
137
+ ostring += "#{tmp_string} "
138
+ else
139
+ ostring += "#{tmp_string} #{tmp_value} "
140
+ end
141
+ end
142
+ end
143
+
144
+ return ostring
145
+
146
+ end
147
+
148
+ end
149
+