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.
172 173 174 175 176 177 178 |
# File 'lib/fluent/plugin/in_dstat.rb', line 172 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.
170 171 172 |
# File 'lib/fluent/plugin/in_dstat.rb', line 170 def cur @cur end |
#previous ⇒ Object
Returns the value of attribute previous.
170 171 172 |
# File 'lib/fluent/plugin/in_dstat.rb', line 170 def previous @previous end |
Instance Method Details
#on_change(prev, cur) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/fluent/plugin/in_dstat.rb', line 180 def on_change(prev, cur) return if cur.size < @pos 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 |