chef-handler-riemann 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a66d3b1ce9b0176e8a14b881c13ada35abf952a
4
- data.tar.gz: 8fddfd25866add5d7da3e3266c93bab034014829
3
+ metadata.gz: fc3804398913092c87c0c48205ce742f2e46f09b
4
+ data.tar.gz: ca10b6bb28095a395871eaca3dfd6ce1bd49a8b5
5
5
  SHA512:
6
- metadata.gz: 3f0115a248733f7723b07451b71e0103f052f9d11edd3a49de8b57492720fd268e15b962dafb660257aaf4a5fab7837ffb7e344b7bc8e1f43bb1e2c798916d8d
7
- data.tar.gz: cf3293717e608225f18683771a0f4a35a7cf113c6543c9a1b475ff3dc06b8d32649ddadec2eb921fbe2b5ff65cd04fa9a97cdf387eb6c6c99842b3c2345353c1
6
+ metadata.gz: e01c327d8232ddee3816cd73946b05540f015aff9ff29d43fc43d1f36c5e2cd101a7dffd5177b1c34971e44a8bf66c3dff988121def6abb58ef9b13f69fb6ed3
7
+ data.tar.gz: cf80b8a484711e6218be5896a96a5497bc3ae547c73b25a36915545b8277944b0cd72c5504a46866a9544136e419f83748f426a8ac976ecb7fa60a48af7d2ac0
data/README.md CHANGED
@@ -1,20 +1,25 @@
1
1
  # chef-handler-riemann
2
+
2
3
  Chef Handler that reports to Riemann.
3
4
 
4
5
  It reports when the Chef run starts and finishes, and outputs associated events depending on outcome.
5
6
 
6
7
  # Usage
7
8
 
8
- TODO: Need to integrate into `chef_handler` cookbook for installation. It will need to install `riemann-client` via `chef_gem`
9
+ This is available as a [gem](https://rubygems.org/gems/chef-handler-riemann)
9
10
 
10
- Editing client.rb works though:
11
+ Because this handler has support for start events, you can't use the `chef_handler` cookbook. Instead, it needs to be added to `client.rb`. The community [chef-client](https://github.com/opscode-cookbooks/chef-client) cookbook can help with this, as it provides easy methods for making `client.rb` load the gem and add the handler. Example usage:
11
12
 
12
13
  ```
13
- require '/var/chef/handlers/riemann.rb'
14
-
15
- riemann = DataSift::RiemannHandler.new host: '192.168.122.1', port: 5555, timeout: 5, ttl: 120
14
+ # Riemann handler
15
+ node.default['chef_client']['load_gems']['chef-handler-riemann'] = {}
16
16
 
17
- start_handlers << riemann
18
- report_handlers << riemann
19
- exception_handlers << rieman
17
+ [ 'start', 'report', 'exception' ].each do |type|
18
+ node.default['chef_client']['config']["#{type}_handlers"] = [
19
+ {
20
+ :class => "Chef::Handler::Riemann",
21
+ :arguments => [ { :host => "localhost" } ]
22
+ }
23
+ ]
24
+ end
20
25
  ```
@@ -4,12 +4,13 @@ require 'riemann/client'
4
4
  class Chef
5
5
  class Handler
6
6
  class Riemann < ::Chef::Handler
7
- attr_writer :host, :port, :ttl, :timeout
7
+ attr_writer :host, :port, :ttl_running, :ttl_finished, :timeout
8
8
 
9
9
  def initialize(options={})
10
10
  @host = options[:host] || 'localhost'
11
11
  @port = options[:port] || 5555
12
- @ttl = options[:ttl] || 3600 # seems reasonable given chef runs every 30 mins by default
12
+ @ttl_running = options[:ttl] || 600
13
+ @ttl_finished = options[:ttl] || 3600 # seems reasonable given chef runs every 30 mins by default
13
14
  @timeout = options[:timeout] || 5
14
15
  end
15
16
 
@@ -23,7 +24,8 @@ class Chef
23
24
  riemann << {
24
25
  :service => 'process:chef-client:state',
25
26
  :state => 'running',
26
- :description => "Chef run has started at #{start_time}"
27
+ :description => "Chef run has started at #{start_time}",
28
+ :ttl => @ttl_running
27
29
  }
28
30
  else
29
31
  # chef run has completed
@@ -35,19 +37,19 @@ class Chef
35
37
  state: 'ok',
36
38
  description: "Chef succeeded at #{end_time}",
37
39
  metric: elapsed_time,
38
- ttl: @ttl
40
+ ttl: @ttl_finished
39
41
  }
40
42
 
41
43
  riemann << {
42
44
  service: "process:chef-client:updated_resources",
43
45
  metric: run_status.updated_resources.length,
44
- ttl: @ttl
46
+ ttl: @ttl_finished
45
47
  }
46
48
 
47
49
  riemann << {
48
50
  service: "process:chef-client:all_resources",
49
51
  metric: run_status.all_resources.length,
50
- ttl: @ttl
52
+ ttl: @ttl_finished
51
53
  }
52
54
  else
53
55
  riemann << {
@@ -55,7 +57,7 @@ class Chef
55
57
  state: 'critical',
56
58
  description: "Chef failed at #{end_time}: " + run_status.formatted_exception,
57
59
  metric: elapsed_time,
58
- ttl: @ttl
60
+ ttl: @ttl_finished
59
61
  }
60
62
  end
61
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-handler-riemann
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Forrow