fluent-plugin-ironio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/README +49 -0
- data/README.md +49 -0
- data/create_fluentd_str +300 -0
- data/fluent-plugin-ironio.gemspec +24 -0
- data/lib/fluent/plugin/in_ironio.rb +127 -0
- data/notes +15 -0
- data/sample/snmp.conf.sample +15 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_in_ironio.rb +24 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c08cc79ed7d4834e80e853891c0ede2cb0e7cff9
|
4
|
+
data.tar.gz: 2fab39d59ba89bec7a758fb5c9168e8338ceaf26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 367805f73557960a5b045c18d01fab3868b1ed41c4820746cfc3d883e42fc60a7c7248e411307ceb842427878ab5ecd4afc1d2024f3787acc3d1814ed396d6c0
|
7
|
+
data.tar.gz: 2d845ebcf4149218e00acd4e591ddf30335800ab62424d01cb190c4702e4eb6fba07f719a3394673fd45ffc6ca6786ad2f8e5616463a4e63a01298484d6a0af9
|
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Fluent::Plugin::NewRelic
|
2
|
+
|
3
|
+
fluent-plugin-ironio is an input plug-in for [Fluentd](http://fluentd.org)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
These instructions assume you already have fluentd installed.
|
8
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
9
|
+
|
10
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'fluent-plugin-ironio'
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install fluent-plugin-ironio
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
Add the following into your fluentd config.
|
22
|
+
|
23
|
+
<source>
|
24
|
+
type ironio # required, chossing the input plugin.
|
25
|
+
endpoint # Optional.
|
26
|
+
projectId # Needed for Ironio
|
27
|
+
token # Needed for Ironio
|
28
|
+
endpointQueue # Needed for Ironio
|
29
|
+
endpointType # Example ironio, kinesis
|
30
|
+
oauthId # authorization key
|
31
|
+
interval # frequency to pull data
|
32
|
+
readOnly # True or false to control deletion of message after it is read
|
33
|
+
</source>
|
34
|
+
|
35
|
+
<match alert.ironio>
|
36
|
+
type stdout
|
37
|
+
</match>
|
38
|
+
|
39
|
+
Now startup fluentd
|
40
|
+
|
41
|
+
$ sudo fluentd -c fluent.conf &
|
42
|
+
|
43
|
+
Send a test trap using net-snmp tools
|
44
|
+
|
45
|
+
$ cd test; rvmsudo ./ironmq.rb
|
46
|
+
|
47
|
+
## To Do
|
48
|
+
1. Change the logic to do a get all call so we process a bunch of alerts at a time.
|
49
|
+
2. Make delete configurable
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Fluent::Plugin::NewRelic
|
2
|
+
|
3
|
+
fluent-plugin-ironio is an input plug-in for [Fluentd](http://fluentd.org)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
These instructions assume you already have fluentd installed.
|
8
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
9
|
+
|
10
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'fluent-plugin-ironio'
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install fluent-plugin-ironio
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
Add the following into your fluentd config.
|
22
|
+
|
23
|
+
<source>
|
24
|
+
type ironio # required, chossing the input plugin.
|
25
|
+
endpoint # Optional.
|
26
|
+
projectId # Needed for Ironio
|
27
|
+
token # Needed for Ironio
|
28
|
+
endpointQueue # Needed for Ironio
|
29
|
+
endpointType # Example ironio, kinesis
|
30
|
+
oauthId # authorization key
|
31
|
+
interval # frequency to pull data
|
32
|
+
readOnly # True or false to control deletion of message after it is read
|
33
|
+
</source>
|
34
|
+
|
35
|
+
<match alert.ironio>
|
36
|
+
type stdout
|
37
|
+
</match>
|
38
|
+
|
39
|
+
Now startup fluentd
|
40
|
+
|
41
|
+
$ sudo fluentd -c fluent.conf &
|
42
|
+
|
43
|
+
Send a test trap using net-snmp tools
|
44
|
+
|
45
|
+
$ cd test; rvmsudo ./ironmq.rb
|
46
|
+
|
47
|
+
## To Do
|
48
|
+
1. Change the logic to do a get all call so we process a bunch of alerts at a time.
|
49
|
+
2. Make delete configurable
|
data/create_fluentd_str
ADDED
@@ -0,0 +1,300 @@
|
|
1
|
+
|
2
|
+
plugin=$1
|
3
|
+
USAGE="USAGE: $0 plugin"
|
4
|
+
if [ -z "$plugin" ]; then
|
5
|
+
echo $USAGE
|
6
|
+
exit
|
7
|
+
fi
|
8
|
+
|
9
|
+
mkdir -p lib/fluent/plugin sample test/plugin
|
10
|
+
|
11
|
+
currdate=`date +"%Y-%m-%d"`
|
12
|
+
|
13
|
+
cat >README <<EOF
|
14
|
+
# Fluent::Plugin::$plugin
|
15
|
+
|
16
|
+
fluent-plugin-$plugin is an input plug-in for [Fluentd](http://fluentd.org)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
These instructions assume you already have fluentd installed.
|
21
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
22
|
+
|
23
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
gem 'fluent-plugin-$plugin'
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install fluent-plugin-$plugin
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
Add the following into your fluentd config.
|
35
|
+
|
36
|
+
<source>
|
37
|
+
type $plugin # required, chossing the input plugin.
|
38
|
+
endpoint # Optional.
|
39
|
+
projectId # Needed for Ironio
|
40
|
+
token # Needed for Ironio
|
41
|
+
endpointQueue # Needed for Ironio
|
42
|
+
endpointType # Example ironio, kinesis
|
43
|
+
oauthId # authorization key
|
44
|
+
interval # frequency to pull data
|
45
|
+
readOnly # True or false to control deletion of message after it is read
|
46
|
+
</source>
|
47
|
+
|
48
|
+
<match alert.$plugin>
|
49
|
+
type stdout
|
50
|
+
</match>
|
51
|
+
|
52
|
+
Now startup fluentd
|
53
|
+
|
54
|
+
$ sudo fluentd -c fluent.conf &
|
55
|
+
|
56
|
+
Send a test trap using net-snmp tools
|
57
|
+
|
58
|
+
$ cd test; rvmsudo ./ironmq.rb
|
59
|
+
|
60
|
+
## To Do
|
61
|
+
1. Change the logic to do a get all call so we process a bunch of alerts at a time.
|
62
|
+
2. Make delete configurable
|
63
|
+
EOF
|
64
|
+
|
65
|
+
cat >README.md <<EOF
|
66
|
+
# Fluent::Plugin::$plugin
|
67
|
+
|
68
|
+
fluent-plugin-$plugin is an input plug-in for [Fluentd](http://fluentd.org)
|
69
|
+
|
70
|
+
## Installation
|
71
|
+
|
72
|
+
These instructions assume you already have fluentd installed.
|
73
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
74
|
+
|
75
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
76
|
+
|
77
|
+
Add this line to your application's Gemfile:
|
78
|
+
|
79
|
+
gem 'fluent-plugin-$plugin'
|
80
|
+
|
81
|
+
Or install it yourself as:
|
82
|
+
|
83
|
+
$ gem install fluent-plugin-$plugin
|
84
|
+
|
85
|
+
## Usage
|
86
|
+
Add the following into your fluentd config.
|
87
|
+
|
88
|
+
<source>
|
89
|
+
type $plugin # required, chossing the input plugin.
|
90
|
+
endpoint # Optional.
|
91
|
+
projectId # Needed for Ironio
|
92
|
+
token # Needed for Ironio
|
93
|
+
endpointQueue # Needed for Ironio
|
94
|
+
endpointType # Example ironio, kinesis
|
95
|
+
oauthId # authorization key
|
96
|
+
interval # frequency to pull data
|
97
|
+
readOnly # True or false to control deletion of message after it is read
|
98
|
+
</source>
|
99
|
+
|
100
|
+
<match alert.$plugin>
|
101
|
+
type stdout
|
102
|
+
</match>
|
103
|
+
|
104
|
+
Now startup fluentd
|
105
|
+
|
106
|
+
$ sudo fluentd -c fluent.conf &
|
107
|
+
|
108
|
+
Send a test trap using net-snmp tools
|
109
|
+
|
110
|
+
$ cd test; rvmsudo ./ironmq.rb
|
111
|
+
|
112
|
+
## To Do
|
113
|
+
1. Change the logic to do a get all call so we process a bunch of alerts at a time.
|
114
|
+
2. Make delete configurable
|
115
|
+
EOF
|
116
|
+
|
117
|
+
|
118
|
+
cat > fluent-plugin-$plugin.gemspec <<EOF
|
119
|
+
# -*- encoding: utf-8 -*-
|
120
|
+
$:.push File.expand_path("../lib", __FILE__)
|
121
|
+
|
122
|
+
Gem::Specification.new do |gem|
|
123
|
+
gem.name = "fluent-plugin-$plugin"
|
124
|
+
gem.version = "0.0.1"
|
125
|
+
gem.date = '$currdate'
|
126
|
+
gem.authors = ["chandrashekar Tippur"]
|
127
|
+
gem.email = ["ctippur@gmail.com"]
|
128
|
+
gem.summary = %q{Fluentd input plugin for $plugin alerts}
|
129
|
+
gem.description = %q{FLuentd plugin for $plugin alerts... WIP}
|
130
|
+
gem.homepage = 'https://github.com/Bigel0w/fluent-plugin-$plugin'
|
131
|
+
gem.license = 'MIT'
|
132
|
+
|
133
|
+
gem.files = `git ls-files`.split($\)
|
134
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
135
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
136
|
+
gem.require_paths = ["lib"]
|
137
|
+
# Add GEM dependencies below
|
138
|
+
# For Example: gem.add_development_dependency "rake", '~> 0.9', '>= 0.9.6'
|
139
|
+
end
|
140
|
+
EOF
|
141
|
+
|
142
|
+
cat >Gemfile <<EOF
|
143
|
+
source 'https://rubygems.org'
|
144
|
+
|
145
|
+
# Specify your gem's dependencies in fluent-plugin-snmp.gemspec
|
146
|
+
gemspec
|
147
|
+
EOF
|
148
|
+
|
149
|
+
|
150
|
+
# Create files
|
151
|
+
|
152
|
+
cat >lib/fluent/plugin/in_${plugin}.rb <<EOF
|
153
|
+
module Fluent
|
154
|
+
|
155
|
+
# Read trap messages as events in to fluentd
|
156
|
+
class NewRelicInput < Input
|
157
|
+
Fluent::Plugin.register_input('$plugin', self)
|
158
|
+
|
159
|
+
# Define default configurations
|
160
|
+
# Example: config_param :tag, :string, :default => "alert.newrelic"
|
161
|
+
config_param :interval, :string, :default => "5"
|
162
|
+
config_param :tag, :string, :default => "alert.$plugin"
|
163
|
+
config_param :endpoint, :string, :default => "" # Optional
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
# Initialize and bring in dependencies
|
168
|
+
def initialize
|
169
|
+
super
|
170
|
+
require 'json'
|
171
|
+
require 'daemons'
|
172
|
+
require 'pp'
|
173
|
+
# Add any other dependencies
|
174
|
+
end # def initialize
|
175
|
+
|
176
|
+
# Load internal and external configs
|
177
|
+
def configure(conf)
|
178
|
+
super
|
179
|
+
@conf = conf
|
180
|
+
# TO DO Add code to choke if config parameters are not there
|
181
|
+
end # def configure
|
182
|
+
|
183
|
+
def start
|
184
|
+
super
|
185
|
+
@loop = Coolio::Loop.new
|
186
|
+
timer_trigger = TimerWatcher.new(@interval, true, &method(:input))
|
187
|
+
timer_trigger.attach(@loop)
|
188
|
+
@thread = Thread.new(&method(:run))
|
189
|
+
$log.info "starting $plugin poller, interval #{@interval}"
|
190
|
+
end
|
191
|
+
|
192
|
+
# Stop Listener and cleanup any open connections.
|
193
|
+
def shutdown
|
194
|
+
super
|
195
|
+
@loop.stop
|
196
|
+
@thread.join
|
197
|
+
end
|
198
|
+
|
199
|
+
def run
|
200
|
+
@loop.run
|
201
|
+
$log.info "Running $plugin Input"
|
202
|
+
end
|
203
|
+
|
204
|
+
# Start $plugin Trap listener
|
205
|
+
# Add the code to run this
|
206
|
+
def input
|
207
|
+
end # def Input
|
208
|
+
|
209
|
+
end # End Input class
|
210
|
+
|
211
|
+
class TimerWatcher < Coolio::TimerWatcher
|
212
|
+
def initialize(interval, repeat, &callback)
|
213
|
+
@callback = callback
|
214
|
+
super(interval, repeat)
|
215
|
+
end
|
216
|
+
|
217
|
+
def on_timer
|
218
|
+
@callback.call
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
end # module Fluent
|
223
|
+
EOF
|
224
|
+
|
225
|
+
|
226
|
+
cat >sample/snmp.conf.sample <<EOF
|
227
|
+
<source>
|
228
|
+
type $plugin # required, chossing the input plugin.
|
229
|
+
endpoint # Optional.
|
230
|
+
interval # frequency to pull data
|
231
|
+
readOnly # True or false. This is to control the deletion of message after it is read
|
232
|
+
# Add any more parameters here
|
233
|
+
</source>
|
234
|
+
|
235
|
+
<match alert.$plugin>
|
236
|
+
type stdout
|
237
|
+
</match>
|
238
|
+
EOF
|
239
|
+
|
240
|
+
|
241
|
+
cat >test/helper.rb <<EOF
|
242
|
+
require 'rubygems'
|
243
|
+
require 'bundler'
|
244
|
+
begin
|
245
|
+
Bundler.setup(:default, :development)
|
246
|
+
rescue Bundler::BundlerError => e
|
247
|
+
$stderr.puts e.message
|
248
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
249
|
+
exit e.status_code
|
250
|
+
end
|
251
|
+
require 'test/unit'
|
252
|
+
|
253
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
254
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
255
|
+
require 'fluent/test'
|
256
|
+
unless ENV.has_key?('VERBOSE')
|
257
|
+
nulllogger = Object.new
|
258
|
+
nulllogger.instance_eval {|obj|
|
259
|
+
def method_missing(method, *args)
|
260
|
+
# pass
|
261
|
+
end
|
262
|
+
}
|
263
|
+
$log = nulllogger
|
264
|
+
end
|
265
|
+
|
266
|
+
require 'fluent/plugin/in_$plugin'
|
267
|
+
|
268
|
+
class Test::Unit::TestCase
|
269
|
+
end
|
270
|
+
EOF
|
271
|
+
|
272
|
+
|
273
|
+
cat >test/plugin/test_in_${plugin}.rb <<EOF
|
274
|
+
require 'helper'
|
275
|
+
|
276
|
+
class ${plugin}TrapInputTest < Test::Unit::TestCase
|
277
|
+
def setup
|
278
|
+
Fluent::Test.setup
|
279
|
+
end
|
280
|
+
|
281
|
+
# Add config here
|
282
|
+
CONFIG = %[
|
283
|
+
# Example hostt 0
|
284
|
+
# Example port 1062
|
285
|
+
# Example tag alert.snmptrap
|
286
|
+
]
|
287
|
+
|
288
|
+
def create_driver(conf=CONFIG)
|
289
|
+
Fluent::Test::InputTestDriver.new(Fluent::${plugin}TrapInput).configure(conf)
|
290
|
+
end
|
291
|
+
|
292
|
+
# Configure the test
|
293
|
+
def test_configure
|
294
|
+
d = create_driver('')
|
295
|
+
# Example assert_equal "0".to_i, d.instance.host
|
296
|
+
# Example assert_equal "1062".to_i, d.instance.port
|
297
|
+
# Example assert_equal 'alert.snmptrap', d.instance.tag
|
298
|
+
end
|
299
|
+
end
|
300
|
+
EOF
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-ironio"
|
6
|
+
gem.version = "0.0.1"
|
7
|
+
gem.date = '2015-01-30'
|
8
|
+
gem.authors = ["chandrashekar Tippur"]
|
9
|
+
gem.email = ["ctippur@gmail.com"]
|
10
|
+
gem.summary = %q{Fluentd input plugin for ironio alerts}
|
11
|
+
gem.description = %q{FLuentd plugin for ironio alerts... WIP}
|
12
|
+
gem.homepage = 'https://github.com/ctippur/fluent-plugin-ironio'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake", '~> 0.9', '>= 0.9.6'
|
21
|
+
gem.add_runtime_dependency "fluentd", '~> 0.10', '>= 0.10.51'
|
22
|
+
gem.add_runtime_dependency "json", '~> 1.1', '>= 1.8.2'
|
23
|
+
gem.add_runtime_dependency "iron_mq", '~> 5.0', '>= 5.8.1'
|
24
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Fluent
|
2
|
+
|
3
|
+
# Read trap messages as events in to fluentd
|
4
|
+
class IronioInput < Input
|
5
|
+
Fluent::Plugin.register_input('ironio', self)
|
6
|
+
|
7
|
+
# Define default configurations
|
8
|
+
config_param :tag, :string, :default => "alert.ironio"
|
9
|
+
config_param :endpoint, :string, :default => "" # Optional
|
10
|
+
config_param :projectId, :string, :default => ""
|
11
|
+
config_param :token, :string, :default => ""
|
12
|
+
config_param :endpointType, :string, :default => "ironio"
|
13
|
+
config_param :oauthId, :string, :default => ""
|
14
|
+
config_param :endpointQueue, :string, :default => ""
|
15
|
+
config_param :interval, :string, :default => "5"
|
16
|
+
config_param :readOnly, :string, :default => "true"
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
# Initialize and bring in dependencies
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
require 'json'
|
24
|
+
require 'daemons'
|
25
|
+
require 'iron_mq'
|
26
|
+
require 'pp'
|
27
|
+
end # def initialize
|
28
|
+
|
29
|
+
# Load internal and external configs
|
30
|
+
def configure(conf)
|
31
|
+
super
|
32
|
+
@conf = conf
|
33
|
+
# TO DO Add code to choke if config parameters are not there
|
34
|
+
end # def configure
|
35
|
+
|
36
|
+
def start
|
37
|
+
super
|
38
|
+
@loop = Coolio::Loop.new
|
39
|
+
timer_trigger = TimerWatcher.new(@interval, true, &method(:input))
|
40
|
+
timer_trigger.attach(@loop)
|
41
|
+
@thread = Thread.new(&method(:run))
|
42
|
+
$log.info "starting ironio poller, interval #{@interval}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Stop Listener and cleanup any open connections.
|
46
|
+
def shutdown
|
47
|
+
super
|
48
|
+
@loop.stop
|
49
|
+
@thread.join
|
50
|
+
end
|
51
|
+
|
52
|
+
def run
|
53
|
+
@loop.run
|
54
|
+
$log.info "Running Ironio Input"
|
55
|
+
end
|
56
|
+
|
57
|
+
# Start SNMP Trap listener
|
58
|
+
def input
|
59
|
+
@ironmq = IronMQ::Client.new(token: @token, project_id: @projectId) # do |event|
|
60
|
+
# Get a Queue object
|
61
|
+
@queue = @ironmq.queue(@endpointQueue)
|
62
|
+
|
63
|
+
# Put a message on the queue
|
64
|
+
#msg = @queue.post("hello world!")
|
65
|
+
|
66
|
+
# Get a message
|
67
|
+
msg = @queue.get()
|
68
|
+
|
69
|
+
# Convert to a proper json
|
70
|
+
#rawMsg=CGI::unescape(msg.raw.to_json).gsub(/"alert=/,'').gsub(/}","timeout/, '},"timeout')
|
71
|
+
#rawMsg=CGI::unescape(jsonhtmlencodedraw).gsub(/"alert=/,'').gsub(/}","timeout/, '},"timeout')
|
72
|
+
|
73
|
+
# Convert to hash
|
74
|
+
#jsonhtmlencodedraw=JSON.parse(rawMsg, :quirks_mode => false) # => "50's & 60's"
|
75
|
+
jsonhtmlencodedraw=JSON.parse(URI.decode((msg.body.split("="))[1]))
|
76
|
+
#argosHash=Hash.new {}
|
77
|
+
#argosHash['newraw']=jsonhtmlencodedraw
|
78
|
+
# Add raw json
|
79
|
+
jsonhtmlencodedraw.merge!('newraw'=>URI.decode((msg.body.split("="))[1]))
|
80
|
+
|
81
|
+
#jsonhtmlencodedraw.store('newraw', jsonhtmlencodedraw)
|
82
|
+
#pp argosHash
|
83
|
+
|
84
|
+
# Add evet_type, intermediary_source, received_time
|
85
|
+
|
86
|
+
#tag = @tag
|
87
|
+
timestamp = Engine.now # Should be received_time_input
|
88
|
+
|
89
|
+
jsonhtmlencodedraw['received_time_input']=timestamp.to_s
|
90
|
+
jsonhtmlencodedraw['event_type']=@tag.to_s
|
91
|
+
jsonhtmlencodedraw['intermediary_source']=jsonhtmlencodedraw['alert_url']
|
92
|
+
#jsonhtmlencodedraw.each do |key, value|
|
93
|
+
# jsonhtmlencodedraw[:key]='"' + value + '"'
|
94
|
+
#end
|
95
|
+
|
96
|
+
$log.info "Incoming message #{jsonhtmlencodedraw}"
|
97
|
+
# Try catch
|
98
|
+
#record = {"value"=> jsonhtmlencodedraw, argosHash.to_json,"tags"=>{"type"=>"alert","application_name"=>jsonhtmlencodedraw["body"]["application_name"]}}
|
99
|
+
begin
|
100
|
+
#Engine.emit('"' + @tag.to_s + '"', '"' + timestamp.to_s + '"' , jsonrawstr)
|
101
|
+
Engine.emit( @tag.to_s , timestamp.to_i , jsonhtmlencodedraw)
|
102
|
+
rescue Exception => e
|
103
|
+
puts e.message
|
104
|
+
puts e.backtrace.inspect
|
105
|
+
end
|
106
|
+
|
107
|
+
# Delete the message. Make this configurable
|
108
|
+
if @readOnly == "false"
|
109
|
+
res = msg.delete # or @queue.delete(msg.id)
|
110
|
+
end
|
111
|
+
end # def Input
|
112
|
+
|
113
|
+
end # End Input class
|
114
|
+
|
115
|
+
class TimerWatcher < Coolio::TimerWatcher
|
116
|
+
def initialize(interval, repeat, &callback)
|
117
|
+
@callback = callback
|
118
|
+
super(interval, repeat)
|
119
|
+
end
|
120
|
+
|
121
|
+
def on_timer
|
122
|
+
@callback.call
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end # module Fluent
|
127
|
+
|
data/notes
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
mkdir fluent-plugin-ironio
|
2
|
+
cd fluent-plugin-ironio
|
3
|
+
git init
|
4
|
+
touch README
|
5
|
+
git add README
|
6
|
+
git commit -m 'first commit'
|
7
|
+
git remote add origin git@gitlab.corp.intuit.net:ioc-tools/fluent-plugin-ironio.git
|
8
|
+
git push -u origin master
|
9
|
+
|
10
|
+
echo "# fluent-plugin-ironio" >> README.md
|
11
|
+
git init
|
12
|
+
git add README.md
|
13
|
+
git commit -m "first commit"
|
14
|
+
git remote add origin git@github.com:ctippur/fluent-plugin-ironio.git
|
15
|
+
git push -u origin master
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<source>
|
2
|
+
type newrelic # required, chossing the input plugin.
|
3
|
+
endpoint # Optional.
|
4
|
+
projectId # Needed for Ironio
|
5
|
+
token # Needed for Ironio
|
6
|
+
endpointQueue # Needed for Ironio
|
7
|
+
endpointType # Example ironio, kinesis
|
8
|
+
oauthId # authorization key
|
9
|
+
interval # frequency to pull data
|
10
|
+
readOnly # True or false. This is to control the deletion of message after it is read
|
11
|
+
</source>
|
12
|
+
|
13
|
+
<match alert.newrelic>
|
14
|
+
type stdout
|
15
|
+
</match>
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/in_ironio'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class IronioInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
]
|
10
|
+
|
11
|
+
def create_driver(conf=CONFIG)
|
12
|
+
Fluent::Test::InputTestDriver.new(Fluent::IronioInput).configure(conf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_configure
|
16
|
+
d = create_driver('')
|
17
|
+
assert_equal "pleasechangeme.com", d.instance.endpoint
|
18
|
+
assert_equal "username", d.instance.user
|
19
|
+
assert_equal "password", d.instance.pass
|
20
|
+
assert_equal "300".to_i, d.instance.interval
|
21
|
+
assert_equal "false", d.instance.include_raw
|
22
|
+
assert_equal 'alert.spectrum', d.instance.tag
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-ironio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chandrashekar Tippur
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.6
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.9'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.6
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: fluentd
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.10'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.10.51
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.10'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.10.51
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.8.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.8.2
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: iron_mq
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '5.0'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 5.8.1
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 5.8.1
|
93
|
+
description: FLuentd plugin for ironio alerts... WIP
|
94
|
+
email:
|
95
|
+
- ctippur@gmail.com
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- Gemfile
|
101
|
+
- README
|
102
|
+
- README.md
|
103
|
+
- create_fluentd_str
|
104
|
+
- fluent-plugin-ironio.gemspec
|
105
|
+
- lib/fluent/plugin/in_ironio.rb
|
106
|
+
- notes
|
107
|
+
- sample/snmp.conf.sample
|
108
|
+
- test/helper.rb
|
109
|
+
- test/plugin/test_in_ironio.rb
|
110
|
+
homepage: https://github.com/ctippur/fluent-plugin-ironio
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Fluentd input plugin for ironio alerts
|
134
|
+
test_files:
|
135
|
+
- test/helper.rb
|
136
|
+
- test/plugin/test_in_ironio.rb
|