class Fluent::XymonOutput
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_xymon.rb, line 6 def initialize super end
Public Instance Methods
build_message(time, record, value)
click to toggle source
# File lib/fluent/plugin/out_xymon.rb, line 52 def build_message time, record, value begin color = @custom_determine_color.call(time, record, value) if @custom_determine_color rescue Exception $log.warn "raises exception: #{$!.class}, '#{$!.message}', '#{@custom_determine_color_code}', '#{time}', '#{record}', '#{value}'" end color ||= @color body = "#{@name_key}=#{value}" message = "status #{@hostname}.#{@testname} #{color} #{Time.at(time)} #{@testname} #{body}\n\n#{body}" message end
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_xymon.rb, line 18 def configure(conf) super @custom_determine_color = nil begin @custom_determine_color = eval("lambda {|time, record, value| #{@custom_determine_color_code}}") if @custom_determine_color_code rescue Exception raise Fluent::ConfigError, "custom_determine_color_code: #{$!.class}, '#{$!.message}'" end end
emit(tag, es, chain)
click to toggle source
# File lib/fluent/plugin/out_xymon.rb, line 38 def emit(tag, es, chain) messages = [] es.each {|time,record| next unless value = record[@name_key] messages.push build_message(time, record, value) } messages.each do |message| post(message) end chain.next end
post(message)
click to toggle source
# File lib/fluent/plugin/out_xymon.rb, line 66 def post(message) begin IO.popen("nc '#{@xymon_server}' '#{@xymon_port}'", 'w') do |io| io.puts message end rescue IOError, EOFError, SystemCallError # server didn't respond $log.warn "raises exception: #{$!.class}, '#{$!.message}'" end message end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_xymon.rb, line 34 def shutdown super end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_xymon.rb, line 30 def start super end