Class: Fluent::LoadAverageInput
- Inherits:
-
Input
- Object
- Input
- Fluent::LoadAverageInput
- Defined in:
- lib/fluent/plugin/in_loadaverage.rb
Defined Under Namespace
Classes: TimerWatcher
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
19 20 21 |
# File 'lib/fluent/plugin/in_loadaverage.rb', line 19 def configure(conf) super end |
#run ⇒ Object
36 37 38 39 40 41 |
# File 'lib/fluent/plugin/in_loadaverage.rb', line 36 def run @loop.run rescue log.error "unexpected error", :error => $!.to_s log.error_backtrace end |
#shutdown ⇒ Object
30 31 32 33 34 |
# File 'lib/fluent/plugin/in_loadaverage.rb', line 30 def shutdown @loop.watchers.each {|w| w.detach } @loop.stop @thread.join end |
#start ⇒ Object
23 24 25 26 27 28 |
# File 'lib/fluent/plugin/in_loadaverage.rb', line 23 def start @loop = Coolio::Loop.new @timer = TimerWatcher.new(@interval, true, &method(:uptime)) @loop.attach(@timer) @thread = Thread.new(&method(:run)) end |
#uptime ⇒ Object
43 44 45 46 47 |
# File 'lib/fluent/plugin/in_loadaverage.rb', line 43 def uptime past1_min, past5_min, past15_min = `uptime`.chomp.match(/load average(?::|s:) (\d+\.\d+)(?:,|) (\d+\.\d+)(?:,|) (\d+\.\d+)$/).to_a.values_at(1,2,3) router.emit(@tag, Engine.now, { past_1min: past1_min, past_5min: past5_min, past_15min: past15_min }) end |