logstash-output-pushover 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27c6825e2be3281fab3feb973a6dc52a6decea27
4
+ data.tar.gz: 293a469d588327d90389f54eb6606ba889044c52
5
+ SHA512:
6
+ metadata.gz: efa880e4ab9a8f5cb9b153bd7c64548bb2a509b05390b9b1271a079964d1f345c86d13cf8663c13ce3e111d1806c1bf69db8ff4d83c5ef2129476586f66957ed
7
+ data.tar.gz: 43045d4ac6614fb842b85fcab91d2e177970ef1019331e5064f1726bc9e1700f61c1063d1d7af217d34c6a32a49fbef14afd9aae4745dc982a2719ed1b71c939
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015 Jasper Lievisse Adriaanse <j@jasper.la>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Logstash Plugin for Pushover output
2
+ ===
3
+
4
+ This is a plugin for [logstash](https://www.elastic.co/products/logstash) to send events to [Pushover](https://pushover.net). It's not an official Pushover-service.
5
+
6
+ Usage
7
+ ---
8
+
9
+ There are two required parameters that need to be set, so at the very least the
10
+ following is required:
11
+
12
+ output {
13
+ pushover {
14
+ app_token => "YOUR_UNIQUE_APP_TOKEN"
15
+ user_key => "RECEIVERS_UNIQUE_USER_KEY"
16
+ }
17
+ }
18
+
19
+ No futher configuration parameters that are listed on [the API specification](https://pushover.net/api)
20
+ are currently enabled.
21
+
22
+ ToDo
23
+ ---
24
+
25
+ - Wire-up additional configuration parameters
26
+ - tests :)
27
+
28
+ Copyright
29
+ ---
30
+
31
+ - 2015 Jasper Lievisse Adriaanse <j@jasper.la>
32
+
33
+ Contributing
34
+ ---
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+
5
+ # Event notification through Pushover.
6
+ # Currently only supports plain messages (event) and no further configuration
7
+ # options are submitted.
8
+ class LogStash::Outputs::Pushover < LogStash::Outputs::Base
9
+ config_name "pushover"
10
+
11
+ # Application token, obtain by registring a new application
12
+ config :app_token, :validate => :string, :require => true
13
+
14
+ # Key for the receiving user
15
+ config :user_key, :validate => :string, :require => true
16
+
17
+ # User device name: https://pushover.net/api#identifiers
18
+ config :device, :validate => :string
19
+
20
+ # Message title: https://pushover.net/api#messages
21
+ config :title, :validate => :string, :default => "Logstash"
22
+
23
+ # Message priority: https://pushover.net/api#priority
24
+ config :priority, :validate => [-2,-1,0,1,2], :default => 0
25
+
26
+ # Timestamp for the message: https://pushover.net/api#timestamp
27
+ config :timestamp, :validate => :string
28
+
29
+ # Notification sound: https://pushover.net/api#sounds
30
+ config :sound, :validate => :string
31
+
32
+ # Supplementary URLs: https://pushover.net/api#urls
33
+ config :url, :validate => :string # XXX: something://rest
34
+
35
+ # Supplementary URL title: https://pushover.net/api#urls
36
+ config :url_title, :validate => :string
37
+
38
+ # Wether to append "tags: <list of tags>" to the event
39
+ config :add_tags, :validate => :boolean, :default => :false
40
+
41
+ # URL of the Pushover API; should generally not be adjusted but it's
42
+ # configurable for testing or in case the something changes upstream and
43
+ # this plugin isn't updated quick enough.
44
+ config :api_url, :validate => :string, :default => 'https://api.pushover.net/1/messages.json'
45
+
46
+ public
47
+ def register
48
+ require 'net/https'
49
+ require 'uri'
50
+ @api_uri = URI.parse(@api_url)
51
+ @client = Net::HTTP.new(@api_uri.host, @api_uri.port)
52
+ end # def register
53
+
54
+ public
55
+ def receive(event)
56
+ return unless output?(event)
57
+
58
+ @logger.info("Pushover event", :event => event)
59
+
60
+ # If requested, add any logstash tags to the message
61
+ message = event.to_s
62
+ if @add_tags
63
+ message += " tags: " + @tags.join(',') if @tags
64
+ end
65
+
66
+ begin
67
+ request = Net::HTTP::Post.new(@api_uri.path)
68
+ request.set_form_data({
69
+ :token => @app_token,
70
+ :user => @user_key,
71
+ :message => event
72
+ })
73
+ # XXX: For any additional configuration keys, add them to the request.
74
+ response = @client
75
+ response.use_ssl = true
76
+ response.verify_mode = OpenSSL::SSL::VERIFY_PEER
77
+ response.start do |http|
78
+ r = http.request(request)
79
+ if status = r.body.match(/"status":(\d+)/)[1] != 1
80
+ @logger.warn("API error", :status => status)
81
+ end
82
+ end
83
+ rescue Exception => e
84
+ @logger.warn("Failed to push notification", :event => event, :exception => e,
85
+ :backtrace => e.backtrace)
86
+ end
87
+ end # def event
88
+ end # class LogStash::Outputs::Pushover
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-pushover'
3
+ s.version = "0.1.0"
4
+ s.licenses = ["ISC"]
5
+ s.summary = "Logstash output to Pushover."
6
+ s.description = "This is a Logstash output for the Pushover push notification service."
7
+ s.authors = ["Jasper Lievisse Adriaanse"]
8
+ s.email = "j@jasper.la"
9
+ s.homepage = "https://github.com/jasperla/logstash-output-pushover"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 1.4.0", "< 2.0.0"
22
+ s.add_development_dependency "logstash-devutils"
23
+ end
@@ -0,0 +1,21 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/outputs/example"
3
+ require "logstash/codecs/plain"
4
+ require "logstash/event"
5
+
6
+ describe LogStash::Outputs::Example do
7
+ let(:sample_event) { LogStash::Event.new }
8
+ let(:output) { LogStash::Outputs::Example.new }
9
+
10
+ before do
11
+ output.register
12
+ end
13
+
14
+ describe "receive message" do
15
+ subject { output.receive(sample_event) }
16
+
17
+ it "returns a string" do
18
+ expect(subject).to eq("Event received")
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-pushover
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jasper Lievisse Adriaanse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: logstash-devutils
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: This is a Logstash output for the Pushover push notification service.
48
+ email: j@jasper.la
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - ".gitignore"
54
+ - Gemfile
55
+ - LICENSE
56
+ - README.md
57
+ - Rakefile
58
+ - lib/logstash/outputs/pushover.rb
59
+ - logstash-output-pushover.gemspec
60
+ - spec/outputs/pushover_spec.rb
61
+ homepage: https://github.com/jasperla/logstash-output-pushover
62
+ licenses:
63
+ - ISC
64
+ metadata:
65
+ logstash_plugin: 'true'
66
+ logstash_group: output
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.3
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Logstash output to Pushover.
87
+ test_files:
88
+ - spec/outputs/pushover_spec.rb