Class: Fluent::DstatInput::DstatCSVWatcher
- Inherits:
-
Cool.io::StatWatcher
- Object
- Cool.io::StatWatcher
- Fluent::DstatInput::DstatCSVWatcher
- Defined in:
- lib/fluent/plugin/in_dstat.rb
Constant Summary collapse
- INTERVAL =
0.500
Instance Attribute Summary collapse
-
#cur ⇒ Object
Returns the value of attribute cur.
-
#previous ⇒ Object
Returns the value of attribute previous.
Instance Method Summary collapse
-
#initialize(path, &receive_lines) ⇒ DstatCSVWatcher
constructor
A new instance of DstatCSVWatcher.
- #on_change(prev, cur) ⇒ Object
Constructor Details
#initialize(path, &receive_lines) ⇒ DstatCSVWatcher
Returns a new instance of DstatCSVWatcher.
150 151 152 153 154 155 156 |
# File 'lib/fluent/plugin/in_dstat.rb', line 150 def initialize(path, &receive_lines) super path, INTERVAL @path = path @io = File.open(path) @pos = 0 @receive_lines = receive_lines end |
Instance Attribute Details
#cur ⇒ Object
Returns the value of attribute cur.
148 149 150 |
# File 'lib/fluent/plugin/in_dstat.rb', line 148 def cur @cur end |
#previous ⇒ Object
Returns the value of attribute previous.
148 149 150 |
# File 'lib/fluent/plugin/in_dstat.rb', line 148 def previous @previous end |
Instance Method Details
#on_change(prev, cur) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/fluent/plugin/in_dstat.rb', line 158 def on_change(prev, cur) buffer = @io.read(cur.size - @pos) @pos = cur.size lines = [] while line = buffer.slice!(/.*?\n/m) lines << line.chomp end @receive_lines.call(lines) end |