Class: Maatkit::QueryDigest

Inherits:
Object
  • Object
show all
Defined in:
lib/maatkit-ruby/mk-query-digest.rb

Overview

Parses logs and more. Analyze, transform, filter, review and report on queries.

Maatkit::QueryDigest.new( array, str, array)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQueryDigest

Returns a new QueryDigest Object



92
93
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 92

def initialize()
end

Instance Attribute Details

#ask_passObject

FALSE



15
16
17
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 15

def ask_pass
  @ask_pass
end

#attribute_aliasesObject

db|Schema



16
17
18
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 16

def attribute_aliases
  @attribute_aliases
end

#attribute_value_limitObject

4294967296



17
18
19
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 17

def attribute_value_limit
  @attribute_value_limit
end

#aux_dsnObject

(No # value)



18
19
20
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 18

def aux_dsn
  @aux_dsn
end

#charsetObject

(No # value)



19
20
21
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 19

def charset
  @charset
end

#check_attributes_limitObject

1000



20
21
22
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 20

def check_attributes_limit
  @check_attributes_limit
end

#configObject

/etc/maatkit/maatkit.conf,/etc/maatkit/mk_query_digest.conf,/home/joel/.maatkit.conf,/home/joel/.mk_query_digest.conf



21
22
23
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 21

def config
  @config
end

#continue_on_errorObject

TRUE



22
23
24
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 22

def continue_on_error
  @continue_on_error
end

#create_review_history_tableObject

FALSE



23
24
25
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 23

def create_review_history_table
  @create_review_history_table
end

#create_review_tableObject

FALSE



24
25
26
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 24

def create_review_table
  @create_review_table
end

#daemonizeObject

FALSE



25
26
27
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 25

def daemonize
  @daemonize
end

#defaults_fileObject

(No # value)



26
27
28
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 26

def defaults_file
  @defaults_file
end

#embedded_attributesObject

(No # value)



27
28
29
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 27

def embedded_attributes
  @embedded_attributes
end

#executeObject

(No # value)



28
29
30
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 28

def execute
  @execute
end

#execute_throttleObject

(No # value)



29
30
31
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 29

def execute_throttle
  @execute_throttle
end

#expected_rangeObject

5,10



30
31
32
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 30

def expected_range
  @expected_range
end

#explainObject

(No # value)



31
32
33
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 31

def explain
  @explain
end

#filterObject

(No # value)



32
33
34
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 32

def filter
  @filter
end

#fingerprintsObject

FALSE



33
34
35
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 33

def fingerprints
  @fingerprints
end

#for_explainObject

TRUE



34
35
36
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 34

def for_explain
  @for_explain
end

#group_byObject

fingerprint



35
36
37
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 35

def group_by
  @group_by
end

#gzipObject

TRUE



36
37
38
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 36

def gzip
  @gzip
end

#helpObject

TRUE



37
38
39
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 37

def help
  @help
end

#hostObject

(No # value)



38
39
40
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 38

def host
  @host
end

#ignore_attributesObject

arg,cmd,insert_id,ip,port,Thread_id,timestamp,exptime,flags,key,res,val,server_id,offset,end_log_pos,Xid



39
40
41
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 39

def ignore_attributes
  @ignore_attributes
end

#inherit_attributesObject

db,ts



40
41
42
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 40

def inherit_attributes
  @inherit_attributes
end

#intervalObject

.1



41
42
43
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 41

def interval
  @interval
end

#iterationsObject

1



42
43
44
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 42

def iterations
  @iterations
end

#limitObject

95%:20



43
44
45
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 43

def limit
  @limit
end

#logObject

(No # value)



44
45
46
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 44

def log
  @log
end

#mirrorObject

(No # value)



45
46
47
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 45

def mirror
  @mirror
end

#order_byObject

Query_time:sum



46
47
48
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 46

def order_by
  @order_by
end

#outliersObject

Query_time:1:10



47
48
49
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 47

def outliers
  @outliers
end

#passwordObject

(No # value)



48
49
50
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 48

def password
  @password
end

#path_to_mk_query_digestObject

Sets the executable path, otherwise the environment path will be used.



87
88
89
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 87

def path_to_mk_query_digest
  @path_to_mk_query_digest
end

#pidObject

(No # value)



49
50
51
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 49

def pid
  @pid
end

#pipeline_profileObject

FALSE



50
51
52
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 50

def pipeline_profile
  @pipeline_profile
end

#portObject

(No # value)



51
52
53
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 51

def port
  @port
end

FALSE



52
53
54
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 52

def print
  @print
end

FALSE



53
54
55
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 53

def print_iterations
  @print_iterations
end

#processlistObject

(No # value)



54
55
56
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 54

def processlist
  @processlist
end

#progressObject

time,30



55
56
57
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 55

def progress
  @progress
end

#read_timeoutObject

(No # value)



56
57
58
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 56

def read_timeout
  @read_timeout
end

#reportObject

TRUE



57
58
59
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 57

def report
  @report
end

#report_allObject

FALSE



58
59
60
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 58

def report_all
  @report_all
end

#report_formatObject

rusage,date,files,header,profile,query_report,prepared



59
60
61
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 59

def report_format
  @report_format
end

#report_histogramObject

Query_time



60
61
62
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 60

def report_histogram
  @report_histogram
end

#reviewObject

(No # value)



61
62
63
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 61

def review
  @review
end

#review_historyObject

(No # value)



62
63
64
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 62

def review_history
  @review_history
end

#run_timeObject

(No # value)



63
64
65
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 63

def run_time
  @run_time
end

#sampleObject

(No # value)



64
65
66
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 64

def sample
  @sample
end

#save_resultsObject

(No # value)



65
66
67
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 65

def save_results
  @save_results
end

#selectObject

Returns the value of attribute select.



66
67
68
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 66

def select
  @select
end

#set_varsObject

wait_timeout=10000



67
68
69
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 67

def set_vars
  @set_vars
end

#shortenObject

1024



68
69
70
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 68

def shorten
  @shorten
end

#show_allObject

Returns the value of attribute show_all.



69
70
71
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 69

def show_all
  @show_all
end

#sinceObject

(No # value)



70
71
72
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 70

def since
  @since
end

#socketObject

(No # value)



71
72
73
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 71

def socket
  @socket
end

#statisticsObject

FALSE



72
73
74
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 72

def statistics
  @statistics
end

#table_accessObject

FALSE



73
74
75
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 73

def table_access
  @table_access
end

#tcpdump_errorsObject

(No # value)



74
75
76
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 74

def tcpdump_errors
  @tcpdump_errors
end

#timelineObject

FALSE



75
76
77
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 75

def timeline
  @timeline
end

#typeObject

slowlog



76
77
78
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 76

def type
  @type
end

#untilObject

(No # value)



77
78
79
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 77

def until
  @until
end

#userObject

(No # value)



78
79
80
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 78

def user
  @user
end

#versionObject

FALSE



79
80
81
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 79

def version
  @version
end

#watch_serverObject

(No # value)



80
81
82
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 80

def watch_server
  @watch_server
end

#zero_adminObject

TRUE



81
82
83
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 81

def zero_admin
  @zero_admin
end

#zero_boolObject

TRUE



82
83
84
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 82

def zero_bool
  @zero_bool
end

Instance Method Details

#start(options = nil) ⇒ Object

Execute the command



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/maatkit-ruby/mk-query-digest.rb', line 98

def start(options = nil)
  tmp = Tempfile.new('tmp')
  command = option_string() + options.to_s + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end