Class: Fluent::ApacheModStatus

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_apache_modstatus.rb

Instance Method Summary collapse

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

#outputObject



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

#runObject



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

#shutdownObject



61
62
63
64
65
# File 'lib/fluent/plugin/in_apache_modstatus.rb', line 61

def shutdown
	@watcher.terminate
	@watcher.join

end

#startObject



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