fluent-plugin-geoblipper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /*.gem
2
+ ~*
3
+ #*
4
+ *~
5
+ .bundle
6
+ Gemfile.lock
7
+ .rbenv-version
8
+ vendor
9
+ doc/*
10
+ tmp/*
11
+ coverage
12
+ .yardoc
13
+ .ruby-version
14
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'pubnub'
4
+ gem 'geoip'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sean Dick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # fluent-plugin-geoblipper
2
+ A fluentd plugin to send a buffered list of lat/long pairs to pubnub.
3
+
4
+ ## Configuration
5
+ * **pubnub_channel** [*string*] Channel to publish to (**REQUIRED*)
6
+ * **pubnub_publish_key** [*string*] Pubnub publishing key (**REQUIRED*)
7
+ * **geodata_location** [*string*] Absolute path to maxmind GeoIP database (**REQUIRED*)
8
+ * **max_entries** [*integer*] Maximum number of lat/long pairs to publish at each flush
9
+ * **ip_key** [*string*] Key to retrieve IP Address from each inbound record (*default: **ip***)
10
+
11
+ Example configuration:
12
+
13
+ <match foo.bar>
14
+ type geoblipper
15
+ pubnub_channel something_good
16
+ pubnub_publish_key pub-c-ABCDE-FGHIJK
17
+ geodata_location /etc/geo/GeoIPCity.dat
18
+ max_entries 30
19
+ ip_key host
20
+ </match>
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.name = "fluent-plugin-geoblipper"
4
+ gem.version = "0.0.1"
5
+ gem.authors = ["Sean Dick", "Change.org"]
6
+ gem.email = ["sean@change.org"]
7
+ gem.homepage = "https://github.com/seanmdick/fluent-plugin-geoblipper"
8
+ gem.summary = %q{Fluentd plugin to send a buffered list of lat/long pairs to pubnub}
9
+ gem.description = %q{Fluentd plugin to convert ips to latitude/longitude pairs for publication on a specified pubnub channel}
10
+ gem.license = "MIT"
11
+
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.require_paths = ["lib"]
15
+
16
+ gem.add_runtime_dependency "fluentd"
17
+ gem.add_runtime_dependency "pubnub"
18
+ gem.add_runtime_dependency "geoip"
19
+
20
+ gem.add_development_dependency "bundler"
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
23
+ end
@@ -0,0 +1,35 @@
1
+ class Fluent::GeoBlipperOutput < Fluent::BufferedOutput
2
+ Fluent::Plugin.register_output('geoblipper', self)
3
+
4
+ def initialize
5
+ super
6
+ require 'geoip'
7
+ require 'pubnub'
8
+ end
9
+
10
+ config_param :pubnub_channel, :string
11
+ config_param :pubnub_publish_key, :string
12
+ config_param :geodata_location, :string
13
+ config_param :max_entries, :integer, :default => -1
14
+ config_param :ip_key, :string, :default => 'ip'
15
+
16
+ def start
17
+ super
18
+ @geodata = GeoIP.new(@geodata_location)
19
+ @pubnub = Pubnub.new( publish_key: @pubnub_publish_key )
20
+ end
21
+
22
+ def format(tag, time, record)
23
+ address = record[@ip_key]
24
+ loc = @geodata.city(address)
25
+ {latitude: loc.latitude, longitude: loc.longitude}.to_json + "\n"
26
+ end
27
+
28
+ def write(chunk)
29
+ chunk.open do |io|
30
+ items = chunk.split("\n")
31
+ entries = items.slice(0..@max_entries).map {|item| JSON.parse(item) }
32
+ @pubnub.publish(message: entries, channel: @pubnub_channel)
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-geoblipper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sean Dick
9
+ - Change.org
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-05-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: fluentd
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: pubnub
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: geoip
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: bundler
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rake
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Fluentd plugin to convert ips to latitude/longitude pairs for publication
112
+ on a specified pubnub channel
113
+ email:
114
+ - sean@change.org
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - fluent-plugin-geoblipper.gemspec
124
+ - lib/fluent/plugin/out_geoblipper.rb
125
+ homepage: https://github.com/seanmdick/fluent-plugin-geoblipper
126
+ licenses:
127
+ - MIT
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 1.8.23
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: Fluentd plugin to send a buffered list of lat/long pairs to pubnub
150
+ test_files: []