maintainer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +57 -0
  4. data/bin/maintainer +23 -0
  5. metadata +67 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06e3729c4804dccc312c4c4d3c04270aa53c53fe
4
+ data.tar.gz: 5d787af7962385c6d51f9df46e181e785be4f090
5
+ SHA512:
6
+ metadata.gz: dac2d0e0a1bfee4c3357577c600db21671c408009ca2715f8ee610a05ab9da62a3796ecb9eec381eab7ba31e7440b80e13ffc034372c28379e5963c6fbacf9be
7
+ data.tar.gz: 311df766fb361395d4678bdbfee14259ebe079dc90c566291a6736df9bee93ad3b5a27ad4d2e0ab31408e4a451059072679773b5d1c94432ab2bcd3aa1251234
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2016 James Turnbull
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Maintainer
2
+
3
+ Sends maintenance events to Riemann.
4
+
5
+ # Getting started
6
+
7
+ ```bash
8
+ gem install maintainer
9
+ maintainer --help
10
+ ```
11
+
12
+ # Usage
13
+
14
+ Generates a maintenance event that you can inject into the Riemann index
15
+ and use to indicate a host is in maintenance mode.
16
+
17
+ ### Starting maintenance
18
+
19
+ ```
20
+ maintainer --host riemann.example.com
21
+ {:host server.example.com, :service maintenance-mode, :state
22
+ active, :description Maintenance is active, :metric nil, :tags nil,
23
+ :time 1457278453, :ttl Infinity}
24
+ ```
25
+
26
+ ### Ending maintenance
27
+
28
+ ```
29
+ maintainer --host riemann.example.com --event-state nil
30
+ {:host server.example.com, :service maintenance-mode, :state
31
+ nil, :description Maintenance is active, :metric nil, :tags nil,
32
+ :time 1457278567, :ttl Infinity}
33
+ ```
34
+
35
+ ### Riemann configuration
36
+
37
+ We would define a function that checks for maintenance events.
38
+
39
+ ```Clojure
40
+ (defn maintenance-mode?
41
+ "Is it currently in maintenance mode?"
42
+ [event]
43
+ (->> '(and (= host (:host event))
44
+ (= service "maintenance-mode"))
45
+ (riemann.index/search (:index @core))
46
+ first
47
+ :state
48
+ (= "active")))
49
+ ```
50
+
51
+ And then use that function to control when notifications are generated:
52
+
53
+ ```Clojure
54
+ (where (not (maintenance-mode? event))
55
+ (pagerduty))
56
+ ```
57
+
data/bin/maintainer ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'riemann/tools'
4
+
5
+ class Maintainer
6
+ include Riemann::Tools
7
+
8
+ opt :event_state, 'State of maintenance event', type: :string, default: 'active'
9
+ opt :event_service, 'Service of maintenance event', type: :string, default: 'maintenance-mode'
10
+
11
+ def initialize
12
+ options[:ttl] = Float::INFINITY
13
+ end
14
+
15
+ def run
16
+ report(:service => options[:event_service],
17
+ :state => options[:event_state],
18
+ :ttl => options[:ttl],
19
+ :description => "Maintenance is active")
20
+ end
21
+
22
+ end
23
+ Maintainer.run
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maintainer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Turnbull
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: riemann-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.2.8
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.8
33
+ description:
34
+ email: james@lovedthanlost.net
35
+ executables:
36
+ - maintainer
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - LICENSE
41
+ - README.md
42
+ - bin/maintainer
43
+ homepage: https://github.com/jamtur01/maintainer
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.8.7
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project: maintainer
63
+ rubygems_version: 2.4.5
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Submits maintainance events to Riemann.
67
+ test_files: []