Class: Fluent::ApacheModStatus
- Inherits:
-
Input
- Object
- Input
- Fluent::ApacheModStatus
- Defined in:
- lib/fluent/plugin/in_apache_modstatus.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #output ⇒ Object
- #run ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #valid_float(value) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
13 14 15 16 17 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 13 def configure(conf) super require 'net/http' require 'uri' end |
#output ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 35 def output record = {} page_content = Net::HTTP.get(URI.parse(@url)) status_values = page_content.lines.map(&:chomp) status_values.each do |item| if item.include? "Scoreboard: " elsif item.include? ": " values = item.split(": ") values[0].downcase! values[0].gsub!(/ /,"_") if valid_float(values[1]) record[values[0]] = values[1].to_f else record[values[0]] = values[1] end end end time = Fluent::Engine.now router.emit(tag,time,record) end |
#run ⇒ Object
28 29 30 31 32 33 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 28 def run while true output sleep @refresh_interval end end |
#shutdown ⇒ Object
61 62 63 64 65 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 61 def shutdown @watcher.terminate @watcher.join end |
#start ⇒ Object
23 24 25 26 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 23 def start super @watcher = Thread.new(&method(:run)) end |
#valid_float(value) ⇒ Object
19 20 21 |
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 19 def valid_float(value) !!Float(value) rescue false end |