From 431b4dd9f4cd6f56e527b3a422126f504205aacd Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sat, 10 Aug 2013 10:45:17 +0900 Subject: [PATCH 1/7] Rename config items - host -> hostname - column -> testname see: http://hobbit.math.cnrs.fr/hobbit/help/manpages/man1/bb.1.html --- lib/fluent/plugin/out_xymon.rb | 6 +++--- spec/lib/fluent/plugin/out_xymon_spec.rb | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/fluent/plugin/out_xymon.rb b/lib/fluent/plugin/out_xymon.rb index 4359995..ae7d910 100644 --- a/lib/fluent/plugin/out_xymon.rb +++ b/lib/fluent/plugin/out_xymon.rb @@ -10,8 +10,8 @@ def initialize config_param :xymon_server, :string config_param :xymon_port, :string, :default => '1984' config_param :color, :string, :default => 'green' - config_param :host, :string - config_param :column, :string + config_param :hostname, :string + config_param :testname, :string config_param :name_key, :string def configure(conf) @@ -42,7 +42,7 @@ def emit(tag, es, chain) def build_message time, value body = "#{@name_key}=#{value}" - message = "status #{@host}.#{@column} #{@color} #{Time.at(time)} #{@column} #{body}\n\n#{body}" + message = "status #{@hostname}.#{@testname} #{@color} #{Time.at(time)} #{@testname} #{body}\n\n#{body}" message end diff --git a/spec/lib/fluent/plugin/out_xymon_spec.rb b/spec/lib/fluent/plugin/out_xymon_spec.rb index 184d54a..f8c725b 100644 --- a/spec/lib/fluent/plugin/out_xymon_spec.rb +++ b/spec/lib/fluent/plugin/out_xymon_spec.rb @@ -5,9 +5,9 @@ %[ xymon_server 127.0.0.1 xymon_port 1984 - color red - host host1 - column column1 + color red + hostname host1 + testname column1 name_key field1 ] } @@ -33,12 +33,12 @@ end context do - subject {driver.instance.host} + subject {driver.instance.hostname} it{should == 'host1'} end context do - subject {driver.instance.column} + subject {driver.instance.testname} it{should == 'column1'} end @@ -52,7 +52,7 @@ describe 'build_message' do context do subject {driver.instance.build_message(0, 50)} - it{should == "status #{driver.instance.host}.#{driver.instance.column} #{driver.instance.color} #{Time.at(0)} #{driver.instance.column} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} + it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} end end From d5a7e4a21d78083b64c052f07a6209d9e6c0be8a Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sat, 10 Aug 2013 10:46:06 +0900 Subject: [PATCH 2/7] Remove dead code --- spec/lib/fluent/plugin/out_xymon_spec.rb | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/spec/lib/fluent/plugin/out_xymon_spec.rb b/spec/lib/fluent/plugin/out_xymon_spec.rb index f8c725b..f20f47a 100644 --- a/spec/lib/fluent/plugin/out_xymon_spec.rb +++ b/spec/lib/fluent/plugin/out_xymon_spec.rb @@ -69,20 +69,5 @@ subject {posted} it{should_not be_nil} end - - # context do - # subject {posted[:data][:message]} - # it{should =~ "status #{driver.instance.host}.#{driver.instance.column} #{driver.instance.color} [^\n]+\n\n#{driver.instance.name_key}=50"} - # end - # - # context do - # subject {posted[:data][:xymon_server]} - # it{should == driver.instance.xymon_server} - # end - # - # context do - # subject {posted[:data][:xymon_port]} - # it{should == driver.instance.xymon_port} - # end end end From f9d17c5968b72b65d3cfe5bf70ed8d12933c5d1d Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sat, 10 Aug 2013 12:23:48 +0900 Subject: [PATCH 3/7] Add custom determine color feature support set ruby code of determinate color to config_param :custom_determine_color_code Parameter ---- time, record, value Example ---- everytime 'green' ```` custom_determine_color_code return 'green' ```` if value > 90 then 'red' else 'green' ```` custom_determine_color_code if value > 90; 'red'; else 'green'; end ```` If raise some exception ---- use config color value and write warn log --- lib/fluent/plugin/out_xymon.rb | 17 +++- spec/lib/fluent/plugin/out_xymon_spec.rb | 108 +++++++++++++++++++++-- 2 files changed, 113 insertions(+), 12 deletions(-) diff --git a/lib/fluent/plugin/out_xymon.rb b/lib/fluent/plugin/out_xymon.rb index ae7d910..c6b1d12 100644 --- a/lib/fluent/plugin/out_xymon.rb +++ b/lib/fluent/plugin/out_xymon.rb @@ -13,9 +13,13 @@ def initialize config_param :hostname, :string config_param :testname, :string config_param :name_key, :string + config_param :custom_determine_color_code, :string, :default => nil def configure(conf) super + + @custom_determine_color = nil + @custom_determine_color = lambda {|time, record, value| eval(@custom_determine_color_code)} if @custom_determine_color_code end def start @@ -31,7 +35,7 @@ def emit(tag, es, chain) es.each {|time,record| next unless value = record[@name_key] - messages.push build_message(time, value) + messages.push build_message(time, record, value) } messages.each do |message| post(message) @@ -40,9 +44,16 @@ def emit(tag, es, chain) chain.next end - def build_message time, value + 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 = "status #{@hostname}.#{@testname} #{color} #{Time.at(time)} #{@testname} #{body}\n\n#{body}" message end diff --git a/spec/lib/fluent/plugin/out_xymon_spec.rb b/spec/lib/fluent/plugin/out_xymon_spec.rb index f20f47a..d78d439 100644 --- a/spec/lib/fluent/plugin/out_xymon_spec.rb +++ b/spec/lib/fluent/plugin/out_xymon_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe do + let(:driver) { + Fluent::Test::OutputTestDriver.new(Fluent::XymonOutput, 'test.metrics').configure(config) + } + let(:config) { %[ xymon_server 127.0.0.1 @@ -12,10 +16,6 @@ ] } - let(:driver) { - Fluent::Test::OutputTestDriver.new(Fluent::XymonOutput, 'test.metrics').configure(config) - } - describe 'config' do context do subject {driver.instance.xymon_server} @@ -47,25 +47,115 @@ it{should == 'field1'} end + describe 'custom_determine_color_code' do + context 'not_exist' do + subject {driver.instance.custom_determine_color_code} + it{should be_nil} + end + + context 'exist' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code return 'green' + ] + } + + subject {driver.instance.custom_determine_color_code} + it{should == "return 'green'"} + end + end end describe 'build_message' do - context do - subject {driver.instance.build_message(0, 50)} + let(:record) {[]} + context 'empty custom_determine_color_code' do + subject {driver.instance.build_message(0, record, 50)} + it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} + end + + context 'valid custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code if value.to_i > 90; 'red'; else 'green'; end + ] + } + + subject {driver.instance.build_message(0, record, 50)} + it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{'green'} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} + end + + context 'invalid syntax custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code (><) + ] + } + + subject {driver.instance.build_message(0, record, 50)} it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} end + end describe 'emit' do - let(:posted) { d = driver mock(IO).popen("nc '#{d.instance.xymon_server}' '#{d.instance.xymon_port}'", 'w').times 1 d.emit({ 'field1' => 50, 'otherfield' => 99}) - d.run + d.run } - context do + context 'empty custom_determine_color_code' do + subject {posted} + it{should_not be_nil} + end + + context 'valid custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code if value.to_i > 90; 'red'; else 'green'; end + ] + } + subject {posted} + it{should_not be_nil} + end + + context 'invalid syntax custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code (><) + ] + } subject {posted} it{should_not be_nil} end From b97f9cdeaa521902a4f35ff713322da5be036fd4 Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sat, 10 Aug 2013 14:28:02 +0900 Subject: [PATCH 4/7] gem version++ --- fluent-plugin-xymon.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluent-plugin-xymon.gemspec b/fluent-plugin-xymon.gemspec index bce303f..9a09da0 100644 --- a/fluent-plugin-xymon.gemspec +++ b/fluent-plugin-xymon.gemspec @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |spec| spec.name = "fluent-plugin-xymon" - spec.version = '0.0.0' + spec.version = '0.0.1' spec.authors = ["bash0C7"] spec.email = ["koshiba+github@4038nullpointer.com"] spec.description = "Fluentd output plugin to post message to xymon" From 56299ca7735cc9087bece2535b2b37e8b761d04b Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sun, 11 Aug 2013 09:49:34 +0900 Subject: [PATCH 5/7] Eval custom_determine_color_code when configure --- lib/fluent/plugin/out_xymon.rb | 9 +- spec/lib/fluent/plugin/out_xymon_spec.rb | 114 ++++++++++++++--------- 2 files changed, 75 insertions(+), 48 deletions(-) diff --git a/lib/fluent/plugin/out_xymon.rb b/lib/fluent/plugin/out_xymon.rb index c6b1d12..f927f42 100644 --- a/lib/fluent/plugin/out_xymon.rb +++ b/lib/fluent/plugin/out_xymon.rb @@ -19,7 +19,12 @@ def configure(conf) super @custom_determine_color = nil - @custom_determine_color = lambda {|time, record, value| eval(@custom_determine_color_code)} if @custom_determine_color_code + 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 def start @@ -72,4 +77,4 @@ def post(message) end end -end \ No newline at end of file +end diff --git a/spec/lib/fluent/plugin/out_xymon_spec.rb b/spec/lib/fluent/plugin/out_xymon_spec.rb index d78d439..886cc1d 100644 --- a/spec/lib/fluent/plugin/out_xymon_spec.rb +++ b/spec/lib/fluent/plugin/out_xymon_spec.rb @@ -53,7 +53,7 @@ it{should be_nil} end - context 'exist' do + context 'valid syntax' do let(:config) { %[ xymon_server 127.0.0.1 @@ -69,17 +69,41 @@ subject {driver.instance.custom_determine_color_code} it{should == "return 'green'"} end + + context 'invalid syntax' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code (><) + ] + } + + subject {lambda{driver.instance.custom_determine_color_code}} + it{should raise_error(Fluent::ConfigError)} + end + end end describe 'build_message' do - let(:record) {[]} + let(:name_key) {'field1'} + + let(:record) {{ name_key => 50, 'otherfield' => 99}} + let(:time) {0} + let(:value) {record[name_key]} + + let(:built) {driver.instance.build_message(time, record, value)} context 'empty custom_determine_color_code' do - subject {driver.instance.build_message(0, record, 50)} + subject {built} it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} end - context 'valid custom_determine_color_code' do + context 'exist custom_determine_color_code' do let(:config) { %[ xymon_server 127.0.0.1 @@ -87,39 +111,37 @@ color red hostname host1 testname column1 - name_key field1 - custom_determine_color_code if value.to_i > 90; 'red'; else 'green'; end + name_key #{name_key} + custom_determine_color_code #{custom_determine_color_code} ] } - subject {driver.instance.build_message(0, record, 50)} - it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{'green'} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} - end + context 'valid custom_determine_color_code' do + let(:custom_determine_color_code) {"if value.to_i > 90; 'red'; else 'green'; end"} - context 'invalid syntax custom_determine_color_code' do - let(:config) { - %[ - xymon_server 127.0.0.1 - xymon_port 1984 - color red - hostname host1 - testname column1 - name_key field1 - custom_determine_color_code (><) - ] - } + subject {built} + it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{'green'} #{Time.at(time)} #{driver.instance.testname} #{driver.instance.name_key}=#{value}\n\n#{driver.instance.name_key}=#{value}"} + end - subject {driver.instance.build_message(0, record, 50)} - it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} - end + context 'invalid syntax custom_determine_color_code' do + let(:custom_determine_color_code) {'Fluent::XymonOutput::UNDEFINED_CONST'} + subject { + mock($log).warn("raises exception: NameError, 'uninitialized constant #{custom_determine_color_code}', 'Fluent::XymonOutput::UNDEFINED_CONST', '#{time}', '#{record.to_s}', '#{record[name_key]}'").times 1 + built + } + it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(time)} #{driver.instance.testname} #{driver.instance.name_key}=#{value}\n\n#{driver.instance.name_key}=#{value}"} + end + end end describe 'emit' do + let(:record) {{ 'field1' => 50, 'otherfield' => 99}} + let(:time) {0} let(:posted) { d = driver mock(IO).popen("nc '#{d.instance.xymon_server}' '#{d.instance.xymon_port}'", 'w').times 1 - d.emit({ 'field1' => 50, 'otherfield' => 99}) + d.emit(record, Time.at(time)) d.run } @@ -128,7 +150,8 @@ it{should_not be_nil} end - context 'valid custom_determine_color_code' do + context 'exist custom_determine_color_code' do + let(:name_key) {'field1'} let(:config) { %[ xymon_server 127.0.0.1 @@ -136,28 +159,27 @@ color red hostname host1 testname column1 - name_key field1 - custom_determine_color_code if value.to_i > 90; 'red'; else 'green'; end + name_key #{name_key} + custom_determine_color_code #{custom_determine_color_code} ] } - subject {posted} - it{should_not be_nil} - end - context 'invalid syntax custom_determine_color_code' do - let(:config) { - %[ - xymon_server 127.0.0.1 - xymon_port 1984 - color red - hostname host1 - testname column1 - name_key field1 - custom_determine_color_code (><) - ] - } - subject {posted} - it{should_not be_nil} + context 'valid custom_determine_color_code' do + let(:custom_determine_color_code) {"if value.to_i > 90; 'red'; else 'green'; end"} + + subject {posted} + it{should_not be_nil} + end + + context 'invalid syntax custom_determine_color_code' do + let(:custom_determine_color_code) {'Fluent::XymonOutput::UNDEFINED_CONST'} + + subject { + mock($log).warn("raises exception: NameError, 'uninitialized constant Fluent::XymonOutput::UNDEFINED_CONST', 'Fluent::XymonOutput::UNDEFINED_CONST', '#{time}', '#{record.to_s}', '#{record[name_key]}'").times 1 + posted + } + it{should_not be_nil} + end end end -end +end \ No newline at end of file From 2e0c389a7f72eed383b3eb5206b2f77eff3d0595 Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sun, 11 Aug 2013 10:08:06 +0900 Subject: [PATCH 6/7] Refactoring spec --- spec/lib/fluent/plugin/out_xymon_spec.rb | 108 ++++++++++++++--------- 1 file changed, 66 insertions(+), 42 deletions(-) diff --git a/spec/lib/fluent/plugin/out_xymon_spec.rb b/spec/lib/fluent/plugin/out_xymon_spec.rb index 886cc1d..41d2eb3 100644 --- a/spec/lib/fluent/plugin/out_xymon_spec.rb +++ b/spec/lib/fluent/plugin/out_xymon_spec.rb @@ -1,59 +1,53 @@ require 'spec_helper' describe do - let(:driver) { - Fluent::Test::OutputTestDriver.new(Fluent::XymonOutput, 'test.metrics').configure(config) - } + let(:driver) {Fluent::Test::OutputTestDriver.new(Fluent::XymonOutput, 'test.metrics').configure(config)} + let(:instance) {driver.instance} - let(:config) { - %[ + describe 'config' do + let(:config) { + %[ xymon_server 127.0.0.1 xymon_port 1984 color red hostname host1 testname column1 name_key field1 - ] - } - - describe 'config' do + ] + } + context do - subject {driver.instance.xymon_server} + subject {instance.xymon_server} it{should == '127.0.0.1'} end context do - subject {driver.instance.xymon_port} + subject {instance.xymon_port} it{should == '1984'} end context do - subject {driver.instance.color} + subject {instance.color} it{should == 'red'} end context do - subject {driver.instance.hostname} + subject {instance.hostname} it{should == 'host1'} end context do - subject {driver.instance.testname} + subject {instance.testname} it{should == 'column1'} end context do - subject {driver.instance.name_key} + subject {instance.name_key} it{should == 'field1'} end describe 'custom_determine_color_code' do context 'not_exist' do - subject {driver.instance.custom_determine_color_code} - it{should be_nil} - end - - context 'valid syntax' do let(:config) { %[ xymon_server 127.0.0.1 @@ -62,31 +56,39 @@ hostname host1 testname column1 name_key field1 - custom_determine_color_code return 'green' ] } - - subject {driver.instance.custom_determine_color_code} - it{should == "return 'green'"} + + subject {instance.custom_determine_color_code} + it{should be_nil} end - context 'invalid syntax' do + context 'exist custom_determine_color_code' do let(:config) { %[ - xymon_server 127.0.0.1 - xymon_port 1984 - color red - hostname host1 - testname column1 - name_key field1 - custom_determine_color_code (><) + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + custom_determine_color_code #{custom_determine_color_code} ] } + context 'valid syntax' do + let(:custom_determine_color_code) {"return 'green'"} - subject {lambda{driver.instance.custom_determine_color_code}} - it{should raise_error(Fluent::ConfigError)} - end + subject {instance.custom_determine_color_code} + it{should == custom_determine_color_code} + end + + context 'invalid syntax' do + let(:custom_determine_color_code) {"(><)"} + subject {lambda{instance.custom_determine_color_code}} + it{should raise_error(Fluent::ConfigError)} + end + end end end @@ -97,10 +99,21 @@ let(:time) {0} let(:value) {record[name_key]} - let(:built) {driver.instance.build_message(time, record, value)} + let(:built) {instance.build_message(time, record, value)} context 'empty custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + ] + } + subject {built} - it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(0)} #{driver.instance.testname} #{driver.instance.name_key}=50\n\n#{driver.instance.name_key}=50"} + it{should == "status #{instance.hostname}.#{instance.testname} #{instance.color} #{Time.at(0)} #{instance.testname} #{instance.name_key}=50\n\n#{instance.name_key}=50"} end context 'exist custom_determine_color_code' do @@ -120,7 +133,7 @@ let(:custom_determine_color_code) {"if value.to_i > 90; 'red'; else 'green'; end"} subject {built} - it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{'green'} #{Time.at(time)} #{driver.instance.testname} #{driver.instance.name_key}=#{value}\n\n#{driver.instance.name_key}=#{value}"} + it{should == "status #{instance.hostname}.#{instance.testname} #{'green'} #{Time.at(time)} #{instance.testname} #{instance.name_key}=#{value}\n\n#{instance.name_key}=#{value}"} end context 'invalid syntax custom_determine_color_code' do @@ -130,7 +143,7 @@ mock($log).warn("raises exception: NameError, 'uninitialized constant #{custom_determine_color_code}', 'Fluent::XymonOutput::UNDEFINED_CONST', '#{time}', '#{record.to_s}', '#{record[name_key]}'").times 1 built } - it{should == "status #{driver.instance.hostname}.#{driver.instance.testname} #{driver.instance.color} #{Time.at(time)} #{driver.instance.testname} #{driver.instance.name_key}=#{value}\n\n#{driver.instance.name_key}=#{value}"} + it{should == "status #{instance.hostname}.#{instance.testname} #{instance.color} #{Time.at(time)} #{instance.testname} #{instance.name_key}=#{value}\n\n#{instance.name_key}=#{value}"} end end end @@ -146,12 +159,23 @@ } context 'empty custom_determine_color_code' do + let(:config) { + %[ + xymon_server 127.0.0.1 + xymon_port 1984 + color red + hostname host1 + testname column1 + name_key field1 + ] + } + subject {posted} it{should_not be_nil} end context 'exist custom_determine_color_code' do - let(:name_key) {'field1'} + let(:name_key) {'field1'} let(:config) { %[ xymon_server 127.0.0.1 @@ -164,14 +188,14 @@ ] } - context 'valid custom_determine_color_code' do + context 'valid code' do let(:custom_determine_color_code) {"if value.to_i > 90; 'red'; else 'green'; end"} subject {posted} it{should_not be_nil} end - context 'invalid syntax custom_determine_color_code' do + context 'runtime error' do let(:custom_determine_color_code) {'Fluent::XymonOutput::UNDEFINED_CONST'} subject { From f473c4486f36695d90dc07ca6ddb1b7e0e4fe3b5 Mon Sep 17 00:00:00 2001 From: Toshiaki Koshiba Date: Sun, 11 Aug 2013 15:43:14 +0900 Subject: [PATCH 7/7] Edit README.md --- README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54f94f8..d4e822e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ Fluentd output plugin to post message to xymon Install gem - fluent-gem install fluent-plugin-xymon +```` +fluent-gem install fluent-plugin-xymon +```` ## config @@ -14,10 +16,57 @@ Install gem config_param :xymon_server, :string config_param :xymon_port, :string, :default => '1984' config_param :color, :string, :default => 'green' - config_param :host, :string - config_param :column, :string + config_param :hostname, :string + config_param :testname, :string config_param :name_key, :string + config_param :custom_determine_color_code, :string, :default => nil +```` + +### example + + + type xymon + xymon_server 127.0.0.1 + xymon_port 1984 + color green + hostname web-server-01 + testname CPU + name_key CPUUtilization + custom_determine_color_code if value.to_i > 90; 'red'; else 'green'; end + + +## config_param :custom_determine_color_code + +set ruby code of determinate color to custom_determine_color_code. + +### Parameter + +time, record, value + +### Example + +#### everytime 'green' + +```` +custom_determine_color_code return 'green' +```` + +#### if value > 90 then 'red' else 'green' + +```` +custom_determine_color_code if value > 90; 'red'; else 'green'; end ```` +### config_param :color + +ignore :color if custom_determine_color_code is exist and valid. +use :color if custom_determine_color_code is noting or invalid + +### If raise some exception + +server didn't respond + +- use config color value +- write warn log ## Contributing @@ -26,3 +75,7 @@ Install gem 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request + +## releases +2013/08/09 0.0.0 1st release +2013/08/10 0.0.1 https://github.com/bash0C7/fluent-plugin-xymon/pull/1