Class: MysqlStatistics
- Inherits:
-
JsonTail::Parser
- Object
- JsonTail::Parser
- MysqlStatistics
- Defined in:
- lib/json_tail/parsers/mysql-statistics.rb
Constant Summary collapse
- ENTRIES =
["SELECT", "INSERT", "DELETE", "UPDATE"]
Instance Attribute Summary collapse
-
#com_delete ⇒ Object
Returns the value of attribute com_delete.
-
#com_insert ⇒ Object
Returns the value of attribute com_insert.
-
#com_select ⇒ Object
Returns the value of attribute com_select.
-
#com_update ⇒ Object
Returns the value of attribute com_update.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ MysqlStatistics
constructor
A new instance of MysqlStatistics.
- #reset ⇒ Object
- #start ⇒ Object
Methods inherited from JsonTail::Parser
Constructor Details
#initialize(filename) ⇒ MysqlStatistics
Returns a new instance of MysqlStatistics.
11 12 13 14 15 16 17 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 11 def initialize(filename) @filename = filename @com_select = 0 @com_insert = 0 @com_delete = 0 @com_update = 0 end |
Instance Attribute Details
#com_delete ⇒ Object
Returns the value of attribute com_delete.
8 9 10 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 8 def com_delete @com_delete end |
#com_insert ⇒ Object
Returns the value of attribute com_insert.
8 9 10 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 8 def com_insert @com_insert end |
#com_select ⇒ Object
Returns the value of attribute com_select.
8 9 10 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 8 def com_select @com_select end |
#com_update ⇒ Object
Returns the value of attribute com_update.
8 9 10 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 8 def com_update @com_update end |
Class Method Details
.build_report(options) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 51 def build_report() mm = self.new(['filename']) content = { "com_select" => mm.com_select, "com_insert" => mm.com_insert, "com_delete" => mm.com_delete, "com_update" => mm.com_update } report(['parser'], content) mm.start end |
Instance Method Details
#reset ⇒ Object
42 43 44 45 46 47 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 42 def reset @com_select = 0 @com_insert = 0 @com_delete = 0 @com_update = 0 end |
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/json_tail/parsers/mysql-statistics.rb', line 19 def start File.open(@filename) do |log| log.extend(File::Tail) log.interval = 10 log.tail do |line| ENTRIES.each do |e| if line.include? e case e when "SELECT" @com_select += 1 when "INSERT" @com_insert += 1 when "DELETE" @com_delete += 1 when "UPDATE" @com_update += 1 end end end end end end |