class Fluent::ApacheModStatus
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_apache_modstatus.rb, line 14 def configure(conf) super require 'net/http' require 'uri' end
output()
click to toggle source
# File lib/fluent/plugin/in_apache_modstatus.rb, line 36 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: " # Scoreboard Key: # "_" Waiting for Connection, "S" Starting up, "R" Reading Request, # "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, # "C" Closing connection, "L" Logging, "G" Gracefully finishing, # "I" Idle cleanup of worker, "." Open slot with no current process values = item.split(": ") scores = values[1].split(//) scoreboard = { "wait" => 0, "start" => 0, "read" => 0, "reply" => 0, "keepalive" => 0, "dns" => 0, "closing" => 0, "log" => 0, "graceful" => 0, "cleanup" => 0, "openslot" => 0 } scores.each do |score| if score == "_" scoreboard["wait"] = scoreboard["wait"] + 1 elsif score == "S" scoreboard["start"] = scoreboard["start"] + 1 elsif score == "R" scoreboard["read"] = scoreboard["read"] + 1 elsif score == "W" scoreboard["reply"] = scoreboard["reply"] + 1 elsif score == "K" scoreboard["keepalive"] = scoreboard["keepalive"] + 1 elsif score == "D" scoreboard["dns"] = scoreboard["dns"] + 1 elsif score == "C" scoreboard["closing"] = scoreboard["closing"] + 1 elsif score == "L" scoreboard["log"] = scoreboard["log"] + 1 elsif score == "G" scoreboard["graceful"] = scoreboard["graceful"] + 1 elsif score == "I" scoreboard["cleanup"] = scoreboard["cleanup"] + 1 elsif score == "." scoreboard["openslot"] = scoreboard["openslot"] + 1 end end scoreboard.each do |key,score| record["scoreboard_count_#{key}"] = score end 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()
click to toggle source
# File lib/fluent/plugin/in_apache_modstatus.rb, line 29 def run while true output sleep @refresh_interval end end
shutdown()
click to toggle source
# File lib/fluent/plugin/in_apache_modstatus.rb, line 113 def shutdown @watcher.terminate @watcher.join end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_apache_modstatus.rb, line 24 def start super @watcher = Thread.new(&method(:run)) end
valid_float(value)
click to toggle source
# File lib/fluent/plugin/in_apache_modstatus.rb, line 20 def valid_float(value) !!Float(value) rescue false end