Class: Fluent::HttpStatusInput

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

Raises:

  • (ConfigError)


31
32
33
34
35
36
37
# File 'lib/fluent/plugin/in_http_status.rb', line 31

def configure(conf)
  super
  @params = @params.split(',').map{|str| str.strip} unless @params.nil?
  @polling_time = @polling_time.split(',').map{|str| str.strip} unless @polling_time.nil?
  raise ConfigError, "snmp: 'polling_time' parameter is required on snmp input" if !@polling_time.nil? && @polling_time.empty?
  @retry_count = 0
end

#runObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fluent/plugin/in_http_status.rb', line 48

def run
  Polling.setting offset: @polling_offset
  Polling.__send__(@polling_type, @polling_time) do
    record = Hash.new
    args = {
      :url => @url,
      :port => @port,
      :proxy_address => @proxy_address,
      :proxy_port => @proxy_port,
      :proxy_user => @proxy_user,
      :proxy_password => @proxy_password,
      :params => @params
    }
    Engine.emit(@tag, Engine.now, get_status(record,args))
    break if @end_flag
  end
rescue TypeError => ex
  $log.error "run TypeError", :error=>ex.message
  exit
rescue => ex
  $log.error "run failed", :error=>ex.message
  @retry_count += 1
  retry if @retry_count < @retry
  exit
end

#shutdownObject



74
75
76
77
78
79
80
81
82
83
# File 'lib/fluent/plugin/in_http_status.rb', line 74

def shutdown
  @end_flag ||= true
  if @thread
    @thread.run
    @thread.join
  end 
  if @starter
    @starter.join
  end
end

#startObject



44
45
46
# File 'lib/fluent/plugin/in_http_status.rb', line 44

def start
  starter{@thread=Thread.new(&method(:run))}
end

#starterObject



39
40
41
42
# File 'lib/fluent/plugin/in_http_status.rb', line 39

def starter
  Net::HTTP.version_1_2
  @starter=Thread.new{yield}
end