fluent-plugin-xymon 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/fluent-plugin-xymon.gemspec +26 -0
- data/lib/fluent/plugin/out_xymon.rb +64 -0
- data/spec/lib/fluent/plugin/out_xymon_spec.rb +88 -0
- data/spec/spec_helper.rb +25 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 05a444f11d59b73e6c13cbdabd095ef3ac6ef4ce
|
4
|
+
data.tar.gz: 09d58df76a427ca0e44110841c491733a63f44d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f47b7bea07822227bae6d9547c29ef700a8016489bc4eb6efb0231933e948fd6f8b0958868bd9b0059fe91bb34740876185640995d2ad64e4fd3c8c56ce2f174
|
7
|
+
data.tar.gz: 542d9765ef316010b966cf390d013963bd8f876ba449be65939bbdfe41d9785e71edfdcc6830a1c7f7b26fa7cea53e27033ff6053a1ea00e4636abb19dead023
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# fluent-plugin-xymon
|
2
|
+
|
3
|
+
Fluentd output plugin to post message to xymon
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install gem
|
8
|
+
|
9
|
+
fluent-gem install fluent-plugin-xymon
|
10
|
+
|
11
|
+
## config
|
12
|
+
|
13
|
+
````ruby
|
14
|
+
config_param :xymon_server, :string
|
15
|
+
config_param :xymon_port, :string, :default => '1984'
|
16
|
+
config_param :color, :string, :default => 'green'
|
17
|
+
config_param :host, :string
|
18
|
+
config_param :column, :string
|
19
|
+
config_param :name_key, :string
|
20
|
+
````
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-xymon"
|
7
|
+
spec.version = '0.0.0'
|
8
|
+
spec.authors = ["bash0C7"]
|
9
|
+
spec.email = ["koshiba+github@4038nullpointer.com"]
|
10
|
+
spec.description = "Fluentd output plugin to post message to xymon"
|
11
|
+
spec.summary = "Fluentd output plugin to post message to xymon"
|
12
|
+
spec.homepage = "https://github.com/bash0C7/fluent-plugin-xymon"
|
13
|
+
spec.license = "Ruby's"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rr"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
module Fluent
|
3
|
+
class Fluent::XymonOutput < Fluent::Output
|
4
|
+
Fluent::Plugin.register_output('xymon', self)
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
config_param :xymon_server, :string
|
11
|
+
config_param :xymon_port, :string, :default => '1984'
|
12
|
+
config_param :color, :string, :default => 'green'
|
13
|
+
config_param :host, :string
|
14
|
+
config_param :column, :string
|
15
|
+
config_param :name_key, :string
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def start
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def shutdown
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def emit(tag, es, chain)
|
30
|
+
messages = []
|
31
|
+
es.each {|time,record|
|
32
|
+
next unless value = record[@name_key]
|
33
|
+
|
34
|
+
messages.push build_message(time, value)
|
35
|
+
}
|
36
|
+
messages.each do |message|
|
37
|
+
post(message)
|
38
|
+
end
|
39
|
+
|
40
|
+
chain.next
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_message time, value
|
44
|
+
body = "#{@name_key}=#{value}"
|
45
|
+
message = "status #{@host}.#{@column} #{@color} #{Time.at(time)} #{@column} #{body}\n\n#{body}"
|
46
|
+
|
47
|
+
message
|
48
|
+
end
|
49
|
+
|
50
|
+
def post(message)
|
51
|
+
begin
|
52
|
+
IO.popen("nc '#{@xymon_server}' '#{@xymon_port}'", 'w') do |io|
|
53
|
+
io.puts message
|
54
|
+
end
|
55
|
+
rescue IOError, EOFError, SystemCallError
|
56
|
+
# server didn't respond
|
57
|
+
$log.warn "raises exception: #{$!.class}, '#{$!.message}'"
|
58
|
+
end
|
59
|
+
|
60
|
+
message
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe do
|
4
|
+
let(:config) {
|
5
|
+
%[
|
6
|
+
xymon_server 127.0.0.1
|
7
|
+
xymon_port 1984
|
8
|
+
color red
|
9
|
+
host host1
|
10
|
+
column column1
|
11
|
+
name_key field1
|
12
|
+
]
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:driver) {
|
16
|
+
Fluent::Test::OutputTestDriver.new(Fluent::XymonOutput, 'test.metrics').configure(config)
|
17
|
+
}
|
18
|
+
|
19
|
+
describe 'config' do
|
20
|
+
context do
|
21
|
+
subject {driver.instance.xymon_server}
|
22
|
+
it{should == '127.0.0.1'}
|
23
|
+
end
|
24
|
+
|
25
|
+
context do
|
26
|
+
subject {driver.instance.xymon_port}
|
27
|
+
it{should == '1984'}
|
28
|
+
end
|
29
|
+
|
30
|
+
context do
|
31
|
+
subject {driver.instance.color}
|
32
|
+
it{should == 'red'}
|
33
|
+
end
|
34
|
+
|
35
|
+
context do
|
36
|
+
subject {driver.instance.host}
|
37
|
+
it{should == 'host1'}
|
38
|
+
end
|
39
|
+
|
40
|
+
context do
|
41
|
+
subject {driver.instance.column}
|
42
|
+
it{should == 'column1'}
|
43
|
+
end
|
44
|
+
|
45
|
+
context do
|
46
|
+
subject {driver.instance.name_key}
|
47
|
+
it{should == 'field1'}
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'build_message' do
|
53
|
+
context do
|
54
|
+
subject {driver.instance.build_message(0, 50)}
|
55
|
+
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"}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'emit' do
|
60
|
+
|
61
|
+
let(:posted) {
|
62
|
+
d = driver
|
63
|
+
mock(IO).popen("nc '#{d.instance.xymon_server}' '#{d.instance.xymon_port}'", 'w').times 1
|
64
|
+
d.emit({ 'field1' => 50, 'otherfield' => 99})
|
65
|
+
d.run
|
66
|
+
}
|
67
|
+
|
68
|
+
context do
|
69
|
+
subject {posted}
|
70
|
+
it{should_not be_nil}
|
71
|
+
end
|
72
|
+
|
73
|
+
# context do
|
74
|
+
# subject {posted[:data][:message]}
|
75
|
+
# it{should =~ "status #{driver.instance.host}.#{driver.instance.column} #{driver.instance.color} [^\n]+\n\n#{driver.instance.name_key}=50"}
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# context do
|
79
|
+
# subject {posted[:data][:xymon_server]}
|
80
|
+
# it{should == driver.instance.xymon_server}
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# context do
|
84
|
+
# subject {posted[:data][:xymon_port]}
|
85
|
+
# it{should == driver.instance.xymon_port}
|
86
|
+
# end
|
87
|
+
end
|
88
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
|
18
|
+
require 'fluent/load'
|
19
|
+
require 'fluent/test'
|
20
|
+
|
21
|
+
require 'fluent/plugin/out_xymon'
|
22
|
+
|
23
|
+
require 'pry'
|
24
|
+
require 'rr'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-xymon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bash0C7
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Fluentd output plugin to post message to xymon
|
98
|
+
email:
|
99
|
+
- koshiba+github@4038nullpointer.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- fluent-plugin-xymon.gemspec
|
110
|
+
- lib/fluent/plugin/out_xymon.rb
|
111
|
+
- spec/lib/fluent/plugin/out_xymon_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: https://github.com/bash0C7/fluent-plugin-xymon
|
114
|
+
licenses:
|
115
|
+
- Ruby's
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.0.5
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Fluentd output plugin to post message to xymon
|
137
|
+
test_files:
|
138
|
+
- spec/lib/fluent/plugin/out_xymon_spec.rb
|
139
|
+
- spec/spec_helper.rb
|